From 76cdfb2a7e542dea7366f1e78788f02f6f70c0f8 Mon Sep 17 00:00:00 2001 From: Amolith Date: Wed, 5 Nov 2025 10:27:43 -0700 Subject: [PATCH] fix(tests): prevent Windows file lock Assisted-by: Claude Sonnet 4.5 via Crush --- .../tui/components/dialogs/models/list_recent_test.go | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/internal/tui/components/dialogs/models/list_recent_test.go b/internal/tui/components/dialogs/models/list_recent_test.go index efc6b0908da807872e080de0fdaacf236ce3a4fc..249c958ec4a34621eabac5190541f8449668f97f 100644 --- a/internal/tui/components/dialogs/models/list_recent_test.go +++ b/internal/tui/components/dialogs/models/list_recent_test.go @@ -11,6 +11,7 @@ import ( tea "github.com/charmbracelet/bubbletea/v2" "github.com/charmbracelet/catwalk/pkg/catwalk" "github.com/charmbracelet/crush/internal/config" + "github.com/charmbracelet/crush/internal/log" "github.com/charmbracelet/crush/internal/tui/exp/list" "github.com/stretchr/testify/require" ) @@ -48,6 +49,9 @@ func readRecentModels(t *testing.T, path string) map[string]any { } func TestModelList_RecentlyUsedSectionAndPrunesInvalid(t *testing.T) { + // Pre-initialize logger to os.DevNull to prevent file lock on Windows. + log.Setup(os.DevNull, false) + // Isolate config/data paths cfgDir := t.TempDir() dataDir := t.TempDir() @@ -154,6 +158,9 @@ func TestModelList_RecentlyUsedSectionAndPrunesInvalid(t *testing.T) { } func TestModelList_PrunesInvalidModelWithinValidProvider(t *testing.T) { + // Pre-initialize logger to os.DevNull to prevent file lock on Windows. + log.Setup(os.DevNull, false) + // Isolate config/data paths cfgDir := t.TempDir() dataDir := t.TempDir() @@ -266,6 +273,9 @@ func TestModelKey_EmptyInputs(t *testing.T) { } func TestModelList_AllRecentsInvalid(t *testing.T) { + // Pre-initialize logger to os.DevNull to prevent file lock on Windows. + log.Setup(os.DevNull, false) + // Isolate config/data paths cfgDir := t.TempDir() dataDir := t.TempDir()