diff options
Diffstat (limited to 'internal/cache/walker_test.go')
-rw-r--r-- | internal/cache/walker_test.go | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/internal/cache/walker_test.go b/internal/cache/walker_test.go index d18bcf5c3..6433b3535 100644 --- a/internal/cache/walker_test.go +++ b/internal/cache/walker_test.go @@ -49,7 +49,8 @@ func TestDiskCacheObjectWalker(t *testing.T) { } } - expectRemovals := cache.ExportMockRemovalCounter.Count() + 4 + expectChecks := cache.ExportMockCheckCounter.Count() + 4 + expectRemovals := cache.ExportMockRemovalCounter.Count() + 2 // disable the initial move-and-clear function since we are only // evaluating the walker @@ -58,7 +59,7 @@ func TestDiskCacheObjectWalker(t *testing.T) { require.NoError(t, config.Validate()) // triggers walker - pollCountersUntil(t, expectRemovals) + pollCountersUntil(t, expectChecks, expectRemovals) for _, p := range shouldExist { assert.FileExists(t, p) @@ -147,20 +148,22 @@ func satisfyConfigValidation(tmpPath string) error { return nil } -func pollCountersUntil(t testing.TB, expectRemovals int) { +func pollCountersUntil(t testing.TB, expectChecks, expectRemovals int) { // poll injected mock prometheus counters until expected events occur timeout := time.After(time.Second) for { select { case <-timeout: t.Fatalf( - "timed out polling prometheus stats; removals: %d", + "timed out polling prometheus stats; checks: %d removals: %d", + cache.ExportMockCheckCounter.Count(), cache.ExportMockRemovalCounter.Count(), ) default: // keep on truckin' } - if cache.ExportMockRemovalCounter.Count() == expectRemovals { + if cache.ExportMockCheckCounter.Count() == expectChecks && + cache.ExportMockRemovalCounter.Count() == expectRemovals { break } time.Sleep(time.Millisecond) |