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

Function TestKeyValueStatusBytes

jetstream/test/kv_test.go:2356–2383  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

2354}
2355
2356func TestKeyValueStatusBytes(t *testing.T) {
2357 s := RunBasicJetStreamServer()
2358 defer shutdownJSServerAndRemoveStorage(t, s)
2359
2360 nc, js := jsClient(t, s)
2361 defer nc.Close()
2362 ctx := context.Background()
2363
2364 kv, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{
2365 Bucket: "TEST",
2366 })
2367 if err != nil {
2368 t.Fatalf("Unexpected error: %v", err)
2369 }
2370
2371 if _, err := kv.Put(ctx, "key", []byte("value")); err != nil {
2372 t.Fatalf("Unexpected error: %v", err)
2373 }
2374
2375 status, err := kv.Status(ctx)
2376 if err != nil {
2377 t.Fatalf("Unexpected error: %v", err)
2378 }
2379
2380 if status.Bytes() == 0 {
2381 t.Fatal("Expected Bytes() to return non-zero value")
2382 }
2383}
2384
2385func TestKeyValueConfig(t *testing.T) {
2386 s := RunBasicJetStreamServer()

Callers

nothing calls this directly

Calls 9

FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
jsClientFunction · 0.70
CreateKeyValueMethod · 0.65
PutMethod · 0.65
StatusMethod · 0.65
BytesMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected