Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for expected_last_subject_sequence #1072

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions async-nats/tests/jetstream_tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -242,6 +263,7 @@ mod jetstream {
.unwrap()
.await
.unwrap();

// Sequence is now 1, so this should fail.
context
.send_publish(
Expand All @@ -252,6 +274,7 @@ mod jetstream {
.unwrap()
.await
.unwrap_err();

// test header shorthand
assert_eq!(stream.info().await.unwrap().state.messages, 5);
context
Expand Down