forked from lavina/lavina
Test roster query
This commit is contained in:
parent
1fbf9c24eb
commit
9fd4575958
|
@ -38,3 +38,32 @@ impl ToXml for RosterQuery {
|
||||||
events.push(Event::Empty(BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS))));
|
events.push(Event::Empty(BytesStart::new(format!(r#"query xmlns="{}""#, XMLNS))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[cfg(test)]
|
||||||
|
mod tests {
|
||||||
|
use super::*;
|
||||||
|
use crate::bind::{Jid, Name, Resource, Server};
|
||||||
|
use crate::client::{Iq, IqType};
|
||||||
|
|
||||||
|
#[test]
|
||||||
|
fn test_parse() {
|
||||||
|
let input =
|
||||||
|
r#"<iq from='juliet@example.com/balcony' id='bv1bs71f' type='get'><query xmlns='jabber:iq:roster'/></iq>"#;
|
||||||
|
|
||||||
|
let result: Iq<RosterQuery> = parse(input).unwrap();
|
||||||
|
assert_eq!(
|
||||||
|
result,
|
||||||
|
Iq {
|
||||||
|
from: Option::from(Jid {
|
||||||
|
name: Option::from(Name("juliet".into())),
|
||||||
|
server: Server("example.com".into()),
|
||||||
|
resource: Option::from(Resource("balcony".into()))
|
||||||
|
}),
|
||||||
|
id: "bv1bs71f".to_string(),
|
||||||
|
to: None,
|
||||||
|
r#type: IqType::Get,
|
||||||
|
body: RosterQuery,
|
||||||
|
}
|
||||||
|
)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
Loading…
Reference in New Issue