Skip to content

Commit

Permalink
Add test for kv::create
Browse files Browse the repository at this point in the history
  • Loading branch information
praveenperera committed Feb 2, 2024
1 parent 7865c71 commit 17bff07
Showing 1 changed file with 29 additions and 0 deletions.
29 changes: 29 additions & 0 deletions nats/tests/kv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -301,6 +301,35 @@ fn key_value_purge() {
assert_eq!(entries.into_iter().count(), 1);
}

#[test]
fn key_value_create() {
let server = nats_server::run_server("tests/configs/jetstream.conf");
let client = nats::connect(server.client_url()).unwrap();
let context = nats::jetstream::new(client);

let bucket = context
.create_key_value(&Config {
bucket: "FOO".to_string(),
history: 10,
..Default::default()
})
.unwrap();

let create = bucket.create("foo", "1");
assert!(create.is_ok());

let create = bucket.create("foo", "1");
assert!(create.is_err());

bucket.delete("foo").unwrap();
let create = bucket.create("foo", "1");
assert!(create.is_ok());

bucket.purge("foo").unwrap();
let create = bucket.create("foo", "1");
assert!(create.is_ok());
}

#[test]
fn key_value_keys() {
let server = nats_server::run_server("tests/configs/jetstream.conf");
Expand Down

0 comments on commit 17bff07

Please sign in to comment.