Plug-ins: a null translations map is refused

A manifest that gives `null` for `translations` or for one of its maps
(`params`, `groups`, `commands`, `options`) is refused with an error
instead of being read as empty. The palette test of translated plug-in
commands uses names no other test's plug-in has.
This commit is contained in:
dotCooCoo committed 2026-11-22 12:31:42 -08:00
1 parent e84336a5c7
commit 5edc81e548
2 files changed
+11 -7

No files matched your search

+6 -3
View File
@@ -64,9 +64,6 @@ impl<'de, T: Deserialize<'de>> Deserialize<'de> for Entries<T> {
fn expecting(&self, f: &mut std::fmt::Formatter) -> std::fmt::Result {
f.write_str("an object")
}
fn visit_unit<E: serde::de::Error>(self) -> std::result::Result<Self::Value, E> {
Ok(Entries::default())
}
fn visit_map<A: serde::de::MapAccess<'de>>(self, mut map: A) -> std::result::Result<Self::Value, A::Error> {
let mut seen = HashSet::new();
let mut out = Vec::new();
@@ -516,6 +513,12 @@ mod tests {
(r#"{"de":{"name":7}}"#, "manifest"),
(r#"["de"]"#, "manifest"),
(r#""de""#, "manifest"),
("null", "expected an object"),
(r#"{"de":null}"#, "manifest"),
(r#"{"de":{"params":null}}"#, "expected an object"),
(r#"{"de":{"groups":null}}"#, "expected an object"),
(r#"{"de":{"commands":null}}"#, "expected an object"),
(r#"{"de":{"params":{"mode":{"options":null}}}}"#, "expected an object"),
] {
let e = Manifest::parse(with(translations).as_bytes()).unwrap_err().to_string();
assert!(e.contains(says), "{translations}: {e}");
+5 -4
View File
@@ -3319,9 +3319,10 @@ mod tests {
fn a_plugin_command_result_shows_the_plugins_translation() {
use vectorcraft_plugins::wat as tpl;
let id = "test.UI.palette_translated";
// Names no other test's plug-in has, since tests running beside this one share the registry.
let manifest = format!(
r#"{{"id":"{id}","name":"Tidy","version":"1","kind":"filter","commands":[{{"id":"grow","label":"Grow"}}],
"translations":{{"de":{{"name":"Aufräumen","commands":{{"grow":{{"label":"Wachsen"}}}}}}}}}}"#
r#"{{"id":"{id}","name":"Groom","version":"1","kind":"filter","commands":[{{"id":"grow","label":"Expand Rim"}}],
"translations":{{"de":{{"name":"Pflegen","commands":{{"grow":{{"label":"Erweitern"}}}}}}}}}}"#
);
vectorcraft_plugins::registry::install_bytes(&wat::parse_str(tpl::returning(&manifest, r#"{"objects":[]}"#)).unwrap()).unwrap();
let key = format!("plugin.{id}.grow");
@@ -3332,9 +3333,9 @@ mod tests {
let (de, fr) = (shown("de"), shown("fr"));
vectorcraft_plugins::registry::remove(id);
let (de, object, plugins) = de.expect("the command is a result");
assert_eq!(de, format!("{object} › {plugins} › Aufräumen › Wachsen"));
assert_eq!(de, format!("{object} › {plugins} › Pflegen › Erweitern"));
let (fr, object, plugins) = fr.expect("the command is a result");
assert_eq!(fr, format!("{object} › {plugins} › Tidy › Grow"));
assert_eq!(fr, format!("{object} › {plugins} › Groom › Expand Rim"));
}
/// A plug-in command whose plug-in translates its name and label into English shows the