cultnet-rs: pin the id refusals of the two subscription messages

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
Meta Vens 2026-11-28 04:39:24 +01:00
commit 8be603acdb

View file

@ -377,3 +377,24 @@ fn a_commit_that_announces_one_change_is_a_single_change_not_a_buffered_commit()
let events = assembler.accept(change("a", "sub", "k1", Some(("c", 1))));
assert_eq!(keys(&events[0]), ["k1"], "C# treats commitCount <= 1 as no commit");
}
#[test]
fn decode_refuses_an_unsubscribe_or_change_without_its_ids() {
for (field, other) in [("messageId", "subscriptionId"), ("subscriptionId", "messageId")] {
let result = decode(vec![
("schemaVersion", s("cultnet.database_unsubscribe.v0")),
(field, s("")),
(other, s("x")),
]);
assert!(error_text(result).contains(field));
}
assert!(error_text(removed(vec![]).and_then(|_| decode(vec![
("schemaVersion", s("cultnet.database_change_raw.v0")),
("messageId", s("m")),
("subscriptionId", s(" ")),
("changeKind", s("removed")),
("recordKey", s("k")),
("schemaId", s("n")),
])))
.contains("subscriptionId"));
}