(t *testing.T)
| 1382 | } |
| 1383 | |
| 1384 | func 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 | |
| 1414 | func TestListKeyValueStores(t *testing.T) { |
| 1415 | tests := []struct { |
nothing calls this directly
no test coverage detected