MCPcopy
hub / github.com/nats-io/nats.go / TestKeyValueBindStore

Function TestKeyValueBindStore

test/kv_test.go:604–631  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

602}
603
604func TestKeyValueBindStore(t *testing.T) {
605 s := RunBasicJetStreamServer()
606 defer shutdownJSServerAndRemoveStorage(t, s)
607
608 nc, js := jsClient(t, s)
609 defer nc.Close()
610
611 _, err := js.CreateKeyValue(&nats.KeyValueConfig{Bucket: "WATCH"})
612 expectOk(t, err)
613
614 // Now bind to it..
615 _, err = js.KeyValue("WATCH")
616 expectOk(t, err)
617
618 // Make sure we can't bind to a non-kv style stream.
619 // We have some protection with stream name prefix.
620 _, err = js.AddStream(&nats.StreamConfig{
621 Name: "KV_TEST",
622 Subjects: []string{"foo"},
623 })
624 expectOk(t, err)
625
626 _, err = js.KeyValue("TEST")
627 expectErr(t, err)
628 if err != nats.ErrBadBucket {
629 t.Fatalf("Expected %v but got %v", nats.ErrBadBucket, err)
630 }
631}
632
633func TestKeyValueDeleteStore(t *testing.T) {
634 s := RunBasicJetStreamServer()

Callers

nothing calls this directly

Calls 10

FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
jsClientFunction · 0.70
expectOkFunction · 0.70
expectErrFunction · 0.70
CreateKeyValueMethod · 0.65
KeyValueMethod · 0.65
AddStreamMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected