A container registry that uses the AT Protocol for manifest storage and S3 for blob storage. atcr.io
docker container atproto go
73
fork

Configure Feed

Select the types of activity you want to include in your feed.

improve unit tests

+18 -11
+5 -2
pkg/appview/db/annotations_test.go
··· 2 2 3 3 import ( 4 4 "database/sql" 5 + "fmt" 6 + "strings" 5 7 "testing" 6 8 ) 7 9 ··· 20 22 21 23 func setupAnnotationsTestDB(t *testing.T) *sql.DB { 22 24 t.Helper() 23 - // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB 24 - db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{}) 25 + // Use a named in-memory DB unique to this test to ensure isolation between tests 26 + safeName := strings.ReplaceAll(t.Name(), "/", "_") 27 + db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{}) 25 28 if err != nil { 26 29 t.Fatalf("Failed to initialize test database: %v", err) 27 30 }
+4 -3
pkg/appview/db/device_store_test.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "fmt" 5 6 "strings" 6 7 "testing" 7 8 "time" ··· 12 13 // setupTestDB creates an in-memory SQLite database for testing 13 14 func setupTestDB(t *testing.T) *DeviceStore { 14 15 t.Helper() 15 - // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB 16 - // This prevents race conditions where different connections see different databases 17 - db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{}) 16 + // Use a named in-memory DB unique to this test to ensure isolation between tests 17 + safeName := strings.ReplaceAll(t.Name(), "/", "_") 18 + db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{}) 18 19 if err != nil { 19 20 t.Fatalf("Failed to initialize test database: %v", err) 20 21 }
+5 -4
pkg/appview/db/hold_store_test.go
··· 2 2 3 3 import ( 4 4 "database/sql" 5 + "fmt" 6 + "strings" 5 7 "testing" 6 8 "time" 7 9 ) ··· 80 82 81 83 func setupHoldTestDB(t *testing.T) *sql.DB { 82 84 t.Helper() 83 - // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB 84 - db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{}) 85 + // Use a named in-memory DB unique to this test to ensure isolation between tests 86 + safeName := strings.ReplaceAll(t.Name(), "/", "_") 87 + db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{}) 85 88 if err != nil { 86 89 t.Fatalf("Failed to initialize test database: %v", err) 87 90 } 88 91 // Limit to single connection to avoid race conditions in tests 89 92 db.SetMaxOpenConns(1) 90 - // Clean slate: shared-cache in-memory DB may retain data from prior subtests 91 - db.Exec("DELETE FROM hold_captain_records") 92 93 t.Cleanup(func() { db.Close() }) 93 94 return db 94 95 }
+4 -2
pkg/appview/db/session_store_test.go
··· 2 2 3 3 import ( 4 4 "context" 5 + "fmt" 5 6 "net/http" 6 7 "net/http/httptest" 7 8 "strings" ··· 12 13 // setupSessionTestDB creates an in-memory SQLite database for testing 13 14 func setupSessionTestDB(t *testing.T) *SessionStore { 14 15 t.Helper() 15 - // Use file::memory: with cache=shared to ensure all connections share the same in-memory DB 16 - db, err := InitDB("file::memory:?cache=shared", LibsqlConfig{}) 16 + // Use a named in-memory DB unique to this test to ensure isolation between tests 17 + safeName := strings.ReplaceAll(t.Name(), "/", "_") 18 + db, err := InitDB(fmt.Sprintf("file:%s?mode=memory&cache=shared", safeName), LibsqlConfig{}) 17 19 if err != nil { 18 20 t.Fatalf("Failed to initialize test database: %v", err) 19 21 }