diff --git a/cmd/server/tests/collections_preview_test.go b/cmd/server/tests/collections_preview_test.go index ef3366e8..41194be8 100644 --- a/cmd/server/tests/collections_preview_test.go +++ b/cmd/server/tests/collections_preview_test.go @@ -2,7 +2,6 @@ package main import ( "bytes" - "context" "encoding/json" "net/http" "net/http/httptest" @@ -367,8 +366,6 @@ func TestPreviewCollection(t *testing.T) { } func createPreviewTestMediaItems(t *testing.T, db *database.Queries, libraryID string, count int) []string { - ctx := context.Background() - libUUID, err := uuid.Parse(libraryID) require.NoError(t, err, "Should parse library ID") diff --git a/cmd/server/tests/facets_integration_test.go b/cmd/server/tests/facets_integration_test.go index dbbabca6..c0bebea2 100644 --- a/cmd/server/tests/facets_integration_test.go +++ b/cmd/server/tests/facets_integration_test.go @@ -318,7 +318,6 @@ func mergeParams(base, extra url.Values) url.Values { // "Baen Books") cross-match at 0.3+ (session gotcha). func facetFixtureBooks(t *testing.T, setup *TestServerSetup, libraryID pgtype.UUID, prefix string) { t.Helper() - ctx := context.Background() books := []struct { title string genre string diff --git a/cmd/server/tests/statistics_test.go b/cmd/server/tests/statistics_test.go index 2e08d9cd..4a4566b0 100644 --- a/cmd/server/tests/statistics_test.go +++ b/cmd/server/tests/statistics_test.go @@ -526,7 +526,6 @@ func TestReadingStatsWeekLibraryScope(t *testing.T) { func TestLibraryUsageStats(t *testing.T) { setup := setupTestServer(t) userID := getRegularUserID(t, setup.DB) - ctx := context.Background() ebooksID := uuid.MustParse(createLibraryDirect(t, setup.DB, userID, fmt.Sprintf("Test Usage Ebooks %d", time.Now().UnixNano()), "ebooks")) @@ -689,7 +688,6 @@ func TestLibraryUsageStats(t *testing.T) { func TestLibraryUsageStats_Visibility(t *testing.T) { setup := setupTestServer(t) userID := getRegularUserID(t, setup.DB) - ctx := context.Background() visibleID := uuid.MustParse(createLibraryDirect(t, setup.DB, userID, fmt.Sprintf("Test Usage Visible %d", time.Now().UnixNano()), "ebooks")) diff --git a/cmd/server/tests/sync_integration_test.go b/cmd/server/tests/sync_integration_test.go index 0bab36b6..c4550cfc 100644 --- a/cmd/server/tests/sync_integration_test.go +++ b/cmd/server/tests/sync_integration_test.go @@ -90,7 +90,6 @@ func createSyncTestDevice(t *testing.T, db *database.Queries, userID pgtype.UUID } func createSyncTestMedia(t *testing.T, db *database.Queries, libraryID pgtype.UUID) pgtype.UUID { - ctx := context.Background() media, err := db.CreateMediaItem(seedCtx(), database.CreateMediaItemParams{ LibraryID: libraryID, diff --git a/cmd/server/tests/test_helpers_test.go b/cmd/server/tests/test_helpers_test.go index 7f451c21..9b68c27b 100644 --- a/cmd/server/tests/test_helpers_test.go +++ b/cmd/server/tests/test_helpers_test.go @@ -509,14 +509,14 @@ func setupTestServer(t *testing.T) *TestServerSetup { // ScopedDB: the test server must behave EXACTLY like the production // wiring (main.go) — every statement through Queries declares the // acting user for RLS, including the search service's raw DBTX path. - // TestServerSetup.DB below is a SEPARATE raw-pool handle used ONLY - // for harness seeding/cleanup: write policies are permissive (no GUC - // read) and every seeded table except media_items is RLS-ungoverned, - // so seeding needs no identity; direct media SELECTs through it - // raise loudly, which is correct — tests read media through HTTP. + // TestServerSetup.DB below is the SEED handle — also ScopedDB-wired + // (required: sqlc :one inserts use RETURNING, which evaluates the + // SELECT policy even on INSERT) — but its callers pass seedCtx(), a + // synthetic identity with no visibility rows, so seeding sees and + // writes everything. Real personas only exist at the HTTP layer. scopedDB := database.NewScopedDB(dbPool) queries := database.New(scopedDB) - seedDB := database.New(dbPool) + seedDB := database.New(database.NewScopedDB(dbPool)) // Wire the tunable settings registry exactly like main.go: Load // populates the cache (missing rows fall back to compiled defaults)