From fbe45af544506a46f99b7f37641ca0b991850a08 Mon Sep 17 00:00:00 2001 From: clawbot <35+clawbot@noreply.example.org> Date: Sun, 4 Oct 2026 06:49:02 +0000 Subject: [PATCH] Test that a reconciliation pass logs nothing once cancelled A reconciliation pass run with an already cancelled context logs no warning, so a periodic tick the eviction loop takes after a stop adds no warning to the one from the pass the stop interrupted. Model: opus-5-5 --- internal/imgcache/eviction_internal_test.go | 24 +++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/internal/imgcache/eviction_internal_test.go b/internal/imgcache/eviction_internal_test.go index cbc2b5c..5b51f18 100644 --- a/internal/imgcache/eviction_internal_test.go +++ b/internal/imgcache/eviction_internal_test.go @@ -1077,6 +1077,30 @@ func TestReconciliationWalksStopOnceCancelled(t *testing.T) { } } +// TestReconciliationPassLogsNoWarningOnceCancelled checks that a +// reconciliation pass run with an already cancelled context logs no +// warning, so a periodic tick the loop takes after a stop adds no +// warning to the one from the pass the stop interrupted. +func TestReconciliationPassLogsNoWarningOnceCancelled(t *testing.T) { + t.Parallel() + + cache, _ := newEvictionTestCache(t, 1<<30) + + var logBuf bytes.Buffer + + cache.log = slog.New(slog.NewJSONHandler(&logBuf, nil)) + + ctx, cancel := context.WithCancel(t.Context()) + cancel() + + cache.runReconciliationPass(ctx) + t.Logf("log output: %s", logBuf.String()) + + if strings.Contains(logBuf.String(), `"level":"WARN"`) { + t.Errorf("runReconciliationPass logged a warning with a cancelled context") + } +} + // TestEvictSourceBlobExcludesConcurrentStoreOfIdenticalContent exercises // the exact TOCTOU window between evictSourceBlob's row-deletion // transaction commit and its content file unlink: a concurrent