test_parse_spec
Some checks are pending
ci/woodpecker/push/woodpecker Pipeline is pending

Signed-off-by: Maxime “pep” Buquet <pep@bouah.net>
This commit is contained in:
Maxime “pep” Buquet 2023-01-10 14:18:02 +01:00
parent b57b36f81a
commit 41849edbb9
Signed by: pep
GPG key ID: DEDA74AEECA9D0F2

View file

@ -270,4 +270,47 @@ mod tests {
);
assert_eq!(parse_receive(buf2).unwrap().1, receive);
}
#[test]
fn test_parse_spec() {
let buf = r#"
[Client] louise
jid: louise@localhost
password: password
-----
louise connects
louise sends:
<presence to="some@room" />
louise receives:
<message from="louise@localhost"
/>
"#;
let mut accounts: HashMap<AccountName, Account> = HashMap::new();
accounts.insert(String::from("louise"), get_account("louise"));
let xml1 = b"<presence to=\"some@room\" />\n\n";
let xml2 = b"<message from=\"louise@localhost\"\n\t\t/>\n\n";
let actions = vec![
Action::Connect(String::from("louise")),
Action::Send(
String::from("louise"),
Element::from_reader_with_prefixes(&xml1[..], String::from(DEFAULT_NS)).unwrap(),
),
Action::Receive(
String::from("louise"),
Element::from_reader_with_prefixes(&xml2[..], String::from(DEFAULT_NS)).unwrap(),
),
];
let spec = Spec { accounts, actions };
assert_eq!(parse_spec(buf), Ok(spec));
}
}