From a66a5408af4a2bc1a5d3b6f5e2f6cfc7f8f8a216 Mon Sep 17 00:00:00 2001 From: Dimitar Dimitrov Date: Wed, 2 Aug 2023 21:31:06 +0300 Subject: [PATCH] Add test case for `expected_last_subject_sequence` --- async-nats/tests/jetstream_tests.rs | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) diff --git a/async-nats/tests/jetstream_tests.rs b/async-nats/tests/jetstream_tests.rs index e5a7fa818..2ea74acd3 100644 --- a/async-nats/tests/jetstream_tests.rs +++ b/async-nats/tests/jetstream_tests.rs @@ -232,6 +232,27 @@ mod jetstream { PublishErrorKind::WrongLastSequence ); + context + .send_publish( + "baz".to_string(), + Publish::build().expected_last_subject_sequence(0), + ) + .await + .unwrap() + .await + .unwrap(); + + // Should not error + context + .send_publish( + "baz".to_string(), + Publish::build().expected_last_subject_sequence(1), + ) + .await + .unwrap() + .await + .unwrap(); + // Check if it works for the other subjects in the stream. context .send_publish( @@ -242,6 +263,7 @@ mod jetstream { .unwrap() .await .unwrap(); + // Sequence is now 1, so this should fail. context .send_publish( @@ -252,6 +274,7 @@ mod jetstream { .unwrap() .await .unwrap_err(); + // test header shorthand assert_eq!(stream.info().await.unwrap().state.messages, 5); context