From 0c22a57f6176b6efa64fa56b6a82c160bc4c21bd Mon Sep 17 00:00:00 2001 From: arasovic Date: Mon, 17 Aug 2026 03:43:44 +0300 Subject: [PATCH] fix: stop the catalog-failure test racing its own deadline TestConfigSetCatalogFailurePreservesConfig installs a fake catalog that fails immediately, then imposed a 10ms deadline on the command. Two outcomes raced: the fake's error, which exits 9, and the deadline, which exits 7. On a loaded macOS runner the deadline won, so CI went red on main while the same commit had passed macOS twice in the pull request runs. The assertion itself was sound throughout: the config was preserved, only the exit code differed. The short deadline bought nothing, because the fake never blocks. Removing it leaves the test just as fast and records why, so it is not added back. The 1ms timeouts in doctor_test.go and models_test.go are the opposite case and stay: their fakes block on the context, so the deadline is what those tests assert. --- internal/cli/config_test.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/internal/cli/config_test.go b/internal/cli/config_test.go index c212721..0262afe 100644 --- a/internal/cli/config_test.go +++ b/internal/cli/config_test.go @@ -10,7 +10,6 @@ import ( "path/filepath" "strings" "testing" - "time" "github.com/arasovic/pi-worker/internal/config" "github.com/arasovic/pi-worker/internal/pi" @@ -363,7 +362,9 @@ func TestConfigSetCatalogFailurePreservesConfig(t *testing.T) { } installConfigPath(t, path) installFakeCatalog(t, &countingCatalog{err: errors.New("catalog unavailable")}) - code, _, _ := runCLI(t, []string{"config", "set", "default-model", "acme/model", "--timeout", (10 * time.Millisecond).String()}, "") + // No --timeout: the fake catalog fails immediately, and a short deadline + // would race that failure and turn exit 9 into exit 7. + code, _, _ := runCLI(t, []string{"config", "set", "default-model", "acme/model"}, "") got, err := config.Load(path) if code != 9 || err != nil || got != before { t.Fatalf("failed catalog = code %d, config %#v, error %v", code, got, err)