Skip to content

Commit

Permalink
Add test to ensure we do nothing if migrations fail during serialization
Browse files Browse the repository at this point in the history
  • Loading branch information
Dekkonot committed Aug 4, 2023
1 parent 63f3dec commit 50b60e7
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
11 changes: 11 additions & 0 deletions rbx_xml/src/tests/basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -334,3 +334,14 @@ fn migrated_properties() {
crate::to_writer_default(&mut encoded, &tree, &[tree.root_ref()]).unwrap();
insta::assert_snapshot!(std::str::from_utf8(&encoded).unwrap());
}

#[test]
fn bad_migrated_property() {
let tree = WeakDom::new(InstanceBuilder::new("Folder").with_children([
InstanceBuilder::new("TextLabel").with_property("Font", Enum::from_u32(u32::MAX)),
]));

let mut encoded = Vec::new();
crate::to_writer_default(&mut encoded, &tree, &[tree.root_ref()]).unwrap();
insta::assert_snapshot!(std::str::from_utf8(&encoded).unwrap());
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
---
source: rbx_xml/src/tests/basic.rs
expression: "std::str::from_utf8(&encoded).unwrap()"
---
<roblox version="4">
<Item class="Folder" referent="0">
<Properties>
<string name="Name">Folder</string>
</Properties>
<Item class="TextLabel" referent="1">
<Properties>
<string name="Name">TextLabel</string>
<token name="Font">4294967295</token>
</Properties>
</Item>
</Item>
</roblox>

0 comments on commit 50b60e7

Please sign in to comment.