[client] Reactions and replies: a test that every payload kind is in KNOWN_KINDS
ci / check (pull_request) Has been cancelled
ci / check (pull_request) Has been cancelled
This commit is contained in:
@@ -1363,4 +1363,40 @@ mod tests {
|
||||
eva.contacts[0].blocked = true;
|
||||
assert_eq!(eva.receive_unknown(0, 2), Ok(None));
|
||||
}
|
||||
|
||||
/// Every kind this client sends is in `KNOWN_KINDS`: a variant left out would arrive as
|
||||
/// *Unsupported* at a client of the same version.
|
||||
#[test]
|
||||
fn every_payload_kind_is_known() {
|
||||
let to = MessageRef {
|
||||
author: Author::from_bytes([1; 16]),
|
||||
seq: 1,
|
||||
};
|
||||
let all = [
|
||||
Payload::Hello {
|
||||
mailbox: MailboxId::from_bytes([0; 16]),
|
||||
post_token: Token::from_bytes([0; 32]),
|
||||
name: "x".into(),
|
||||
},
|
||||
Payload::Text {
|
||||
body: "x".into(),
|
||||
seq: 1,
|
||||
reply_to: None,
|
||||
},
|
||||
Payload::Receipt { upto: 1 },
|
||||
Payload::Inbox {
|
||||
post_token: Token::from_bytes([0; 32]),
|
||||
},
|
||||
Payload::Reaction { to, emoji: None },
|
||||
];
|
||||
assert_eq!(all.len(), KNOWN_KINDS.len());
|
||||
for payload in all {
|
||||
let json = serde_json::to_vec(&payload).expect("json");
|
||||
assert!(
|
||||
matches!(parse_payload(&json), Ok(Parsed::Known(p)) if p == payload),
|
||||
"{}",
|
||||
String::from_utf8_lossy(&json)
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user