mirror of
https://github.com/storytold/craft-libs.git
synced 2026-11-16 15:33:12 +00:00
crs: a repeated name keeps its first value, as craft-metadata reads it
craft-metadata #1042 keeps the first text-bearing value of a repeated property so a blank repeat cannot hide a location, but craft-crs's doc comment and test still claimed the last repeat wins. The workspace-wide test job has been red since it landed because of that assertion.
This commit is contained in:
1 parent
e85bd30bb2
commit
e98299546f
2 files changed
+8
-3
No files matched your search
@@ -74,7 +74,8 @@ impl Value {
|
||||
}
|
||||
|
||||
/// The `crs:` settings of a packet, by name without the prefix (`Exposure2012`). Where a name
|
||||
/// occurs more than once (in several `rdf:Description`s), the last one is kept.
|
||||
/// occurs more than once (in several `rdf:Description`s), the first text-bearing value is kept,
|
||||
/// as [`craft_metadata::parse_xmp`] reads every packet: a blank repeat must not hide it.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
pub struct Settings {
|
||||
pub entries: BTreeMap<String, Value>,
|
||||
|
||||
@@ -78,10 +78,14 @@ fn structures_other_prefixes_and_other_namespaces() {
|
||||
assert_eq!(masks.items().first().and_then(|m| m.field("crs:What")).and_then(XmpValue::text), Some("Correction"));
|
||||
assert_eq!(s.get("Empty"), Some(&Value::Text(String::new())));
|
||||
assert_eq!(s.get("format"), None);
|
||||
// The last value of a repeated name wins.
|
||||
// A repeated name keeps its first value, as `craft_metadata` reads every packet: an empty
|
||||
// repeat must not hide what an earlier description said.
|
||||
let second = format!("/><rdf:Description xmlns:crs=\"{CRS_NS}\" crs:Texture=\"2\"/></rdf:RDF>");
|
||||
let twice = with("crs:Texture=\"1\"").replace("/></rdf:RDF>", &second);
|
||||
assert_eq!(Settings::parse(twice.as_bytes()).unwrap().text("Texture"), Some("2"));
|
||||
assert_eq!(Settings::parse(twice.as_bytes()).unwrap().text("Texture"), Some("1"));
|
||||
let blank = format!("/><rdf:Description xmlns:crs=\"{CRS_NS}\" crs:Texture=\"\"/></rdf:RDF>");
|
||||
let hiding = with("crs:Texture=\"1\"").replace("/></rdf:RDF>", &blank);
|
||||
assert_eq!(Settings::parse(hiding.as_bytes()).unwrap().text("Texture"), Some("1"), "a blank repeat does not win");
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
||||
Reference in new issue
Block a user