fix: apply dedup window + max_deliver to existing jetstream stream/consumer

This commit is contained in:
2026-10-26 01:35:33 +01:00
parent 818ab893a1
commit 2fb577af65
2 changed files with 96 additions and 1 deletions

View File

@@ -44,3 +44,46 @@ fn decode_message_rejects_a_malformed_id() {
fn decode_message_rejects_garbage() {
assert!(decode_message(b"{not json").is_err());
}
#[test]
fn stream_with_the_default_window_is_updated_and_keeps_other_fields() {
let existing = StreamConfig {
name: "S".into(),
max_messages: 42,
duplicate_window: std::time::Duration::from_secs(120),
..Default::default()
};
let updated = stream_config_update(&existing).unwrap();
assert_eq!(updated.duplicate_window, DEDUP_WINDOW);
assert_eq!(updated.max_messages, 42);
assert_eq!(updated.name, "S");
}
#[test]
fn stream_with_the_right_window_is_left_alone() {
let existing = StreamConfig {
duplicate_window: DEDUP_WINDOW,
..Default::default()
};
assert!(stream_config_update(&existing).is_none());
}
#[test]
fn consumer_max_deliver_drift_is_updated() {
let existing = jetstream::consumer::Config {
durable_name: Some("c".into()),
filter_subject: "a.>".into(),
max_deliver: -1,
ack_wait: ACK_WAIT,
..Default::default()
};
let updated = consumer_config_update(&existing, 5).unwrap();
assert_eq!(updated.max_deliver, 5);
assert_eq!(updated.durable_name.as_deref(), Some("c"));
assert_eq!(updated.filter_subject, "a.>");
let same = jetstream::consumer::Config {
max_deliver: 5,
..existing
};
assert!(consumer_config_update(&same, 5).is_none());
}