diff --git a/cmd/server/tests/search_test.go b/cmd/server/tests/search_test.go index ae9a1f0..32ae25c 100644 --- a/cmd/server/tests/search_test.go +++ b/cmd/server/tests/search_test.go @@ -388,6 +388,7 @@ func TestCollectionSearchLibraryFilter(t *testing.T) { query string libraryID string expectedCount int + expectedStatus int shouldContain string // Comma-separated list of book IDs to check }{ { @@ -412,10 +413,10 @@ func TestCollectionSearchLibraryFilter(t *testing.T) { shouldContain: book2ID, }, { - name: "invalid library_id", - query: "Harry", - libraryID: "00000000-0000-0000-0000-000000000000", - expectedCount: 0, + name: "invalid library_id", + query: "Harry", + libraryID: "00000000-0000-0000-0000-000000000000", + expectedStatus: http.StatusNotFound, }, } @@ -435,10 +436,9 @@ func TestCollectionSearchLibraryFilter(t *testing.T) { _ = Body.Close() }(resp.Body) - // Log response for debugging - if resp.StatusCode != http.StatusOK { - bodyBytes, _ := io.ReadAll(resp.Body) - t.Logf("ERROR %d: %s", resp.StatusCode, string(bodyBytes)) + if tt.expectedStatus != 0 { + require.Equal(t, tt.expectedStatus, resp.StatusCode) + return } var result []map[string]interface{}