(t *testing.T)
| 393 | } |
| 394 | |
| 395 | func TestStore_ValidationMonitor(t *testing.T) { |
| 396 | t.Run("RunsPeriodically", func(t *testing.T) { |
| 397 | db, sqldb := testingutil.MustOpenDBs(t) |
| 398 | defer testingutil.MustCloseDBs(t, db, sqldb) |
| 399 | |
| 400 | levels := litestream.CompactionLevels{ |
| 401 | {Level: 0}, |
| 402 | {Level: 1, Interval: time.Hour}, |
| 403 | } |
| 404 | store := litestream.NewStore([]*litestream.DB{db}, levels) |
| 405 | store.CompactionMonitorEnabled = false |
| 406 | store.ValidationInterval = 50 * time.Millisecond |
| 407 | |
| 408 | if err := store.Open(t.Context()); err != nil { |
| 409 | t.Fatal(err) |
| 410 | } |
| 411 | |
| 412 | // Wait for at least one validation cycle |
| 413 | time.Sleep(100 * time.Millisecond) |
| 414 | |
| 415 | if err := store.Close(t.Context()); err != nil { |
| 416 | t.Fatal(err) |
| 417 | } |
| 418 | }) |
| 419 | |
| 420 | t.Run("DisabledByDefault", func(t *testing.T) { |
| 421 | levels := litestream.CompactionLevels{ |
| 422 | {Level: 0}, |
| 423 | } |
| 424 | store := litestream.NewStore(nil, levels) |
| 425 | store.CompactionMonitorEnabled = false |
| 426 | |
| 427 | // ValidationInterval should be zero by default |
| 428 | if store.ValidationInterval != 0 { |
| 429 | t.Errorf("expected ValidationInterval=0, got %v", store.ValidationInterval) |
| 430 | } |
| 431 | |
| 432 | // Open should succeed without starting validation monitor |
| 433 | if err := store.Open(t.Context()); err != nil { |
| 434 | t.Fatal(err) |
| 435 | } |
| 436 | if err := store.Close(t.Context()); err != nil { |
| 437 | t.Fatal(err) |
| 438 | } |
| 439 | }) |
| 440 | } |
| 441 | |
| 442 | func TestStore_SetRetentionEnabled(t *testing.T) { |
| 443 | db0, sqldb0 := testingutil.MustOpenDBs(t) |
nothing calls this directly
no test coverage detected