parsers: fix tests with --features disable-validation and/or component
This disables a bunch of tests when the component feature is disabled, because that feature changes the namespace of the <message/> element, which causes the tests to fail. Thanks to debacle for finding this.
This commit is contained in:
parent
109356f129
commit
65c1f5ab10
7 changed files with 16 additions and 4 deletions
|
|
@ -24,6 +24,7 @@ XXXX-YY-ZZ RELEASER <admin@example.com>
|
|||
- ibr::LegacyQuery now implements Default, allowing users to more
|
||||
easily construct it (!660)
|
||||
- jingle_rtp::Description gained a bandwidth child.
|
||||
- Fix cargo test for the disable-validation and component features.
|
||||
|
||||
Version 0.22.0:
|
||||
2025-10-28 pep <pep@bouah.net>
|
||||
|
|
|
|||
|
|
@ -58,6 +58,7 @@ impl MessagePayload for Sent {}
|
|||
#[cfg(test)]
|
||||
mod tests {
|
||||
use super::*;
|
||||
#[cfg(not(feature = "component"))]
|
||||
use jid::Jid;
|
||||
use minidom::Element;
|
||||
|
||||
|
|
@ -94,6 +95,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn forwarded_elements() {
|
||||
let elem: Element = "<received xmlns='urn:xmpp:carbons:2'>
|
||||
<forwarded xmlns='urn:xmpp:forward:0'>
|
||||
|
|
@ -135,6 +137,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_serialize_received() {
|
||||
let reference: Element = "<received xmlns='urn:xmpp:carbons:2'><forwarded xmlns='urn:xmpp:forward:0'><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/></forwarded></received>"
|
||||
.parse()
|
||||
|
|
@ -154,6 +157,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_serialize_sent() {
|
||||
let reference: Element = "<sent xmlns='urn:xmpp:carbons:2'><forwarded xmlns='urn:xmpp:forward:0'><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/></forwarded></sent>"
|
||||
.parse()
|
||||
|
|
|
|||
|
|
@ -485,6 +485,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "disable-validation"))]
|
||||
fn test_wrong_child() {
|
||||
let elem: Element = "<x xmlns='jabber:x:data' type='cancel'><coucou/></x>"
|
||||
.parse()
|
||||
|
|
|
|||
|
|
@ -47,6 +47,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_simple() {
|
||||
let elem: Element =
|
||||
"<forwarded xmlns='urn:xmpp:forward:0'><message xmlns='jabber:client'/></forwarded>"
|
||||
|
|
@ -56,6 +57,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
#[cfg_attr(feature = "disable-validation", should_panic = "Result::unwrap_err")]
|
||||
fn test_invalid_child() {
|
||||
let elem: Element = "<forwarded xmlns='urn:xmpp:forward:0'><message xmlns='jabber:client'/><coucou/></forwarded>"
|
||||
|
|
@ -70,6 +72,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_serialise() {
|
||||
let elem: Element = "<forwarded xmlns='urn:xmpp:forward:0'><message xmlns='jabber:client' type='chat'/></forwarded>".parse().unwrap();
|
||||
let forwarded = Forwarded {
|
||||
|
|
@ -81,6 +84,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_serialize_with_delay_and_stanza() {
|
||||
let reference: Element = "<forwarded xmlns='urn:xmpp:forward:0'><delay xmlns='urn:xmpp:delay' from='capulet.com' stamp='2002-09-10T23:08:25+00:00'/><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/></forwarded>"
|
||||
.parse()
|
||||
|
|
@ -123,6 +127,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_invalid_duplicate_message() {
|
||||
let elem: Element = "<forwarded xmlns='urn:xmpp:forward:0'><delay xmlns='urn:xmpp:delay' from='capulet.com' stamp='2002-09-10T23:08:25+00:00'/><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/></forwarded>"
|
||||
.parse()
|
||||
|
|
|
|||
|
|
@ -300,6 +300,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(feature = "disable-validation", should_panic = "Result::unwrap_err")]
|
||||
fn test_invalid_child() {
|
||||
let elem: Element = "<query xmlns='urn:xmpp:mam:2'><coucou/></query>"
|
||||
.parse()
|
||||
|
|
@ -350,6 +351,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "component"))] // feature = "component" changes <message/> namespace
|
||||
fn test_serialize_result() {
|
||||
let reference: Element = "<result xmlns='urn:xmpp:mam:2' queryid='f27' id='28482-98726-73623'><forwarded xmlns='urn:xmpp:forward:0'><delay xmlns='urn:xmpp:delay' stamp='2002-09-10T23:08:25+00:00'/><message xmlns='jabber:client' to='juliet@capulet.example/balcony' from='romeo@montague.example/home'/></forwarded></result>"
|
||||
.parse()
|
||||
|
|
|
|||
|
|
@ -130,6 +130,7 @@ mod tests {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(feature = "disable-validation", should_panic = "Result::unwrap_err")]
|
||||
fn test_invalid_child() {
|
||||
let elem: Element = "<set xmlns='http://jabber.org/protocol/rsm'><coucou/></set>"
|
||||
.parse()
|
||||
|
|
|
|||
|
|
@ -140,10 +140,6 @@ fn empty_unexpected_attribute() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg_attr(
|
||||
feature = "disable-validation",
|
||||
should_panic = "unexpected result: Ok("
|
||||
)]
|
||||
fn empty_ignores_xml_lang() {
|
||||
#[allow(unused_imports)]
|
||||
use core::{
|
||||
|
|
@ -1651,6 +1647,7 @@ fn element_catch_one_negative_none() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "disable-validation"))]
|
||||
fn element_catch_one_negative_more_than_one_child() {
|
||||
#[allow(unused_imports)]
|
||||
use core::{
|
||||
|
|
@ -1693,6 +1690,7 @@ fn element_catch_maybe_one_roundtrip_some() {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[cfg(not(feature = "disable-validation"))]
|
||||
fn element_catch_maybe_one_negative_more_than_one_child() {
|
||||
#[allow(unused_imports)]
|
||||
use core::{
|
||||
|
|
|
|||
Loading…
Reference in a new issue