From b4b18ca53b4452758ad79c957b38f90b92670087 Mon Sep 17 00:00:00 2001 From: Cristian Magherusan-Stanciu Date: Fri, 16 Oct 2026 13:32:42 +0200 Subject: [PATCH] fix(scheduler): make the stale-refresh control test independent of the missing background-collection marker ListRecommendations only kicks a stale refresh when the ctx carries WithBackgroundCollection (issue #627). The twin tests from #938 used a bare context.Background(), so the positive control never saw a refresh (5s timeout in CI) and the negative twin passed vacuously. The tests were written against a base without that gate and merged after it landed. Mark the helper ctx with WithBackgroundCollection. Verified: positive control fails before the change on current main and passes after; the #308-shape mutation (resolveEffectiveCacheTTL not returning disabled for 0) fails the negative test. Co-Authored-By: Claude Opus 5.5 --- internal/scheduler/scheduler_test.go | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/internal/scheduler/scheduler_test.go b/internal/scheduler/scheduler_test.go index 571cbf477..8aa458227 100644 --- a/internal/scheduler/scheduler_test.go +++ b/internal/scheduler/scheduler_test.go @@ -945,7 +945,9 @@ func TestScheduler_ListRecommendations(t *testing.T) { // returned channel and fails, which ends the refresh immediately. func staleListRecommendations(t *testing.T, staleHours int) <-chan struct{} { t.Helper() - ctx := context.Background() + // Only a WithBackgroundCollection ctx may kick a refresh (issue #627); without + // it both twins would pass or fail for the wrong reason. + ctx := WithBackgroundCollection(context.Background()) mockStore := new(MockConfigStore) old := time.Now().Add(-72 * time.Hour)