From ea7abd7476f421841601b47228dfc8821610dbcf Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Thu, 29 Jan 2026 21:16:35 -0500 Subject: [PATCH] test: improve integration test error reporting for library creation - Add explicit status code check (require.Equal 201) - Remove conditional success/failure branching - Provide clear error message with actual vs expected status Now if CreateLibrary returns 500, test will clearly show: "Failed to create library: expected 201, got 500" Instead of vague "Library ID is empty" message that hid the 500 error. --- cmd/server/tests/integration_test.go | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/cmd/server/tests/integration_test.go b/cmd/server/tests/integration_test.go index 0d9787a..6c323a9 100644 --- a/cmd/server/tests/integration_test.go +++ b/cmd/server/tests/integration_test.go @@ -285,16 +285,14 @@ func setupTestSuite(t *testing.T) *TestContext { resp = makeRequest(t, "POST", "/api/libraries", libReq, ctx.AdminToken) defer resp.Body.Close() - if resp.StatusCode == http.StatusCreated || resp.StatusCode == http.StatusOK { - var lib map[string]interface{} - body, _ := io.ReadAll(resp.Body) - err := json.Unmarshal(body, &lib) - require.NoError(t, err) + require.Equal(t, http.StatusCreated, resp.StatusCode, "Failed to create library") - ctx.LibraryID = lib["id"].(string) - t.Logf("Created new library: %v", lib["name"]) - } + var lib map[string]interface{} + body, _ := io.ReadAll(resp.Body) + err := json.Unmarshal(body, &lib) + require.NoError(t, err) + ctx.LibraryID = lib["id"].(string) require.NotEmpty(t, ctx.LibraryID, "Library ID is empty") })