Fix Windows CI test failures
Two Windows-specific test failures: 1. TestNewSQLiteStorage - File locking on temp cleanup - Windows couldn't delete temp database file because connection was still open - Added defer store.Close() to properly cleanup the database connection - Without this, Windows file locking prevents TempDir cleanup 2. TestFindAllDatabases - Unexpected nil slice return - FindAllDatabases could return nil instead of empty slice when os.Getwd() fails - Changed from var databases to explicit empty slice initialization - Ensures function always returns non-nil slice, matching test expectations Both issues are more pronounced on Windows due to stricter file locking and different filesystem behavior. Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
@@ -18,6 +18,7 @@ func TestNewSQLiteStorage(t *testing.T) {
|
|||||||
if err != nil {
|
if err != nil {
|
||||||
t.Fatalf("NewSQLiteStorage failed: %v", err)
|
t.Fatalf("NewSQLiteStorage failed: %v", err)
|
||||||
}
|
}
|
||||||
|
defer store.Close()
|
||||||
|
|
||||||
if store == nil {
|
if store == nil {
|
||||||
t.Error("expected non-nil storage")
|
t.Error("expected non-nil storage")
|
||||||
|
|||||||
@@ -345,7 +345,7 @@ func findDatabaseInTree() string {
|
|||||||
// Returns a slice of DatabaseInfo for each database found, starting from the
|
// Returns a slice of DatabaseInfo for each database found, starting from the
|
||||||
// closest to CWD (most relevant) to the furthest (least relevant).
|
// closest to CWD (most relevant) to the furthest (least relevant).
|
||||||
func FindAllDatabases() []DatabaseInfo {
|
func FindAllDatabases() []DatabaseInfo {
|
||||||
var databases []DatabaseInfo
|
databases := []DatabaseInfo{} // Initialize to empty slice, never return nil
|
||||||
seen := make(map[string]bool) // Track canonical paths to avoid duplicates
|
seen := make(map[string]bool) // Track canonical paths to avoid duplicates
|
||||||
|
|
||||||
dir, err := os.Getwd()
|
dir, err := os.Getwd()
|
||||||
|
|||||||
Reference in New Issue
Block a user