diff --git a/cmd/server/tests/test_helpers.go b/cmd/server/tests/test_helpers.go index 4f41ff3..4c86779 100644 --- a/cmd/server/tests/test_helpers.go +++ b/cmd/server/tests/test_helpers.go @@ -529,6 +529,16 @@ func setupTestServer(t *testing.T) *TestServerSetup { } } + // Delete test libraries (names containing "test" - case insensitive) + // This cleans up libraries created by tests while preserving user-created libraries + // NOTE: Do not use "test" in library names if you want to keep them! + allLibs, _ := queries.ListLibraries(ctx) + for _, lib := range allLibs { + if strings.Contains(strings.ToLower(lib.Name), "test") { + queries.DeleteLibrary(ctx, lib.ID) + } + } + // Create fresh admin test user passwordHash := "$2a$10$JjAtK7PPa1WexQC3AUGe8OXLeuseZ/haN1Mz7emMo6CfOvMiTVXWq" adminUser, err := queries.CreateUser(ctx, database.CreateUserParams{ diff --git a/docs/contributing/development.md b/docs/contributing/development.md index 2c4ca19..33113aa 100644 --- a/docs/contributing/development.md +++ b/docs/contributing/development.md @@ -279,6 +279,15 @@ Environment variables for testing: **⚠️ WARNING**: Never enable these in production! +### Test Library Naming Convention + +Integration tests automatically clean up libraries with "test" in the name (case-insensitive). + +**⚠️ IMPORTANT**: Do not use "test" in library names if you want to keep them! +- Libraries containing "test" (e.g., "My Test Library", "Test Library 1") will be deleted by test cleanup +- Use names like "Development Library", "Staging Books", or "Personal" for libraries you want to keep +- This ensures your manual test data persists between test runs + ## 📝 Code Style Guidelines ### Go Code