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

Function TestKeyValueDuplicatesWindow

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

Source from the content-addressed store, hash-verified

1382}
1383
1384func TestKeyValueDuplicatesWindow(t *testing.T) {
1385 s := RunBasicJetStreamServer()
1386 defer shutdownJSServerAndRemoveStorage(t, s)
1387
1388 nc, js := jsClient(t, s)
1389 defer nc.Close()
1390 ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
1391 defer cancel()
1392
1393 checkWindow := func(ttl, expectedDuplicates time.Duration) {
1394 t.Helper()
1395
1396 _, err := js.CreateKeyValue(ctx, jetstream.KeyValueConfig{Bucket: "TEST", History: 5, TTL: ttl})
1397 expectOk(t, err)
1398 defer func() { expectOk(t, js.DeleteKeyValue(ctx, "TEST")) }()
1399
1400 si, err := js.Stream(ctx, "KV_TEST")
1401 if err != nil {
1402 t.Fatalf("StreamInfo error: %v", err)
1403 }
1404 if si.CachedInfo().Config.Duplicates != expectedDuplicates {
1405 t.Fatalf("Expected duplicates to be %v, got %v", expectedDuplicates, si.CachedInfo().Config.Duplicates)
1406 }
1407 }
1408
1409 checkWindow(0, 2*time.Minute)
1410 checkWindow(time.Hour, 2*time.Minute)
1411 checkWindow(5*time.Second, 5*time.Second)
1412}
1413
1414func TestListKeyValueStores(t *testing.T) {
1415 tests := []struct {

Callers

nothing calls this directly

Calls 10

FatalfMethod · 0.80
RunBasicJetStreamServerFunction · 0.70
jsClientFunction · 0.70
expectOkFunction · 0.70
CreateKeyValueMethod · 0.65
DeleteKeyValueMethod · 0.65
StreamMethod · 0.65
CachedInfoMethod · 0.65
CloseMethod · 0.45

Tested by

no test coverage detected