···2233import (
44 "database/sql"
55+ "fmt"
66+ "strings"
57 "testing"
68)
79···20222123func setupAnnotationsTestDB(t *testing.T) *sql.DB {
2224 t.Helper()
2323- // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB
2424- db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{})
2525+ // Use a named in-memory DB unique to this test to ensure isolation between tests
2626+ safeName := strings.ReplaceAll(t.Name(), "/", "_")
2727+ db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{})
2528 if err != nil {
2629 t.Fatalf("Failed to initialize test database: %v", err)
2730 }
+4-3
pkg/appview/db/device_store_test.go
···2233import (
44 "context"
55+ "fmt"
56 "strings"
67 "testing"
78 "time"
···1213// setupTestDB creates an in-memory SQLite database for testing
1314func setupTestDB(t *testing.T) *DeviceStore {
1415 t.Helper()
1515- // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB
1616- // This prevents race conditions where different connections see different databases
1717- db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{})
1616+ // Use a named in-memory DB unique to this test to ensure isolation between tests
1717+ safeName := strings.ReplaceAll(t.Name(), "/", "_")
1818+ db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{})
1819 if err != nil {
1920 t.Fatalf("Failed to initialize test database: %v", err)
2021 }
+5-4
pkg/appview/db/hold_store_test.go
···2233import (
44 "database/sql"
55+ "fmt"
66+ "strings"
57 "testing"
68 "time"
79)
···80828183func setupHoldTestDB(t *testing.T) *sql.DB {
8284 t.Helper()
8383- // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB
8484- db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{})
8585+ // Use a named in-memory DB unique to this test to ensure isolation between tests
8686+ safeName := strings.ReplaceAll(t.Name(), "/", "_")
8787+ db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{})
8588 if err != nil {
8689 t.Fatalf("Failed to initialize test database: %v", err)
8790 }
8891 // Limit to single connection to avoid race conditions in tests
8992 db.SetMaxOpenConns(1)
9090- // Clean slate: shared-cache in-memory DB may retain data from prior subtests
9191- db.Exec("DELETE FROM hold_captain_records")
9293 t.Cleanup(func() { db.Close() })
9394 return db
9495}
+4-2
pkg/appview/db/session_store_test.go
···2233import (
44 "context"
55+ "fmt"
56 "net/http"
67 "net/http/httptest"
78 "strings"
···1213// setupSessionTestDB creates an in-memory SQLite database for testing
1314func setupSessionTestDB(t *testing.T) *SessionStore {
1415 t.Helper()
1515- // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB
1616- db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{})
1616+ // Use a named in-memory DB unique to this test to ensure isolation between tests
1717+ safeName := strings.ReplaceAll(t.Name(), "/", "_")
1818+ db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{})
1719 if err != nil {
1820 t.Fatalf("Failed to initialize test database: %v", err)
1921 }