Skip to content

Commit

Permalink
Ignore encoding case in assert_xml_eq
Browse files Browse the repository at this point in the history
This fixes flaky tests where encoding is either `utf-8` or `UTF-8`.
  • Loading branch information
DmitrySamoylov committed Nov 13, 2024
1 parent 925a4e8 commit 3c45b5a
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion schema/src/tests/utils.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,26 @@
use xml::reader::XmlEvent;

pub fn assert_xml_eq(actual: &str, expected: &str) {
for (a, e) in without_whitespaces(actual).zip(without_whitespaces(expected)) {
assert_eq!(a, e);
match (a, e) {
(
Ok(XmlEvent::StartDocument {
version,
encoding,
standalone,
}),
Ok(XmlEvent::StartDocument {
version: version_expected,
encoding: encoding_expected,
standalone: standalone_expected,
}),
) => {
assert_eq!(version, version_expected);
assert_eq!(encoding.to_lowercase(), encoding_expected.to_lowercase());
assert_eq!(standalone, standalone_expected);
}
(a, e) => assert_eq!(a, e),
}
}
}

Expand Down

0 comments on commit 3c45b5a

Please # to comment.