From 50b60e7b35f5859b39b86330f80b148541422591 Mon Sep 17 00:00:00 2001 From: Dekkonot Date: Thu, 3 Aug 2023 22:50:12 -0700 Subject: [PATCH] Add test to ensure we do nothing if migrations fail during serialization --- rbx_xml/src/tests/basic.rs | 11 +++++++++++ ...ml__tests__basic__bad_migrated_property.snap | 17 +++++++++++++++++ 2 files changed, 28 insertions(+) create mode 100644 rbx_xml/src/tests/snapshots/rbx_xml__tests__basic__bad_migrated_property.snap diff --git a/rbx_xml/src/tests/basic.rs b/rbx_xml/src/tests/basic.rs index d44698ff4..2fd9391ad 100644 --- a/rbx_xml/src/tests/basic.rs +++ b/rbx_xml/src/tests/basic.rs @@ -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()); +} diff --git a/rbx_xml/src/tests/snapshots/rbx_xml__tests__basic__bad_migrated_property.snap b/rbx_xml/src/tests/snapshots/rbx_xml__tests__basic__bad_migrated_property.snap new file mode 100644 index 000000000..96c75fbb1 --- /dev/null +++ b/rbx_xml/src/tests/snapshots/rbx_xml__tests__basic__bad_migrated_property.snap @@ -0,0 +1,17 @@ +--- +source: rbx_xml/src/tests/basic.rs +expression: "std::str::from_utf8(&encoded).unwrap()" +--- + + + + Folder + + + + TextLabel + 4294967295 + + + +