From ed4a8bd17148c7a5f0a063926d958c1af477135d Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Wed, 11 Feb 2026 17:35:18 -0500 Subject: [PATCH] fix: expect 422 for invalid ISBN updates Test "Update with invalid ISBN rejects" should expect: - 422 Unprocessable Entity status (not 200 OK) - ISBN field should be empty/nil in response (not normalized value) Invalid ISBN with trailing hyphens cannot be normalized to valid ISBN-13. --- cmd/server/tests/media_item_isbn_test.go | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) diff --git a/cmd/server/tests/media_item_isbn_test.go b/cmd/server/tests/media_item_isbn_test.go index d2cd71f..499bbfb 100644 --- a/cmd/server/tests/media_item_isbn_test.go +++ b/cmd/server/tests/media_item_isbn_test.go @@ -493,7 +493,7 @@ func TestUpdateMediaItemISBN(t *testing.T) { mediaItemID := createResponse["id"].(string) // Now update with new ISBN - t.Run("Update with normalized ISBN", func(t *testing.T) { + t.Run("Update with invalid ISBN rejects", func(t *testing.T) { updatePayload := map[string]interface{}{ "title": "Updated Title", "isbn": "978-9876543210-9", @@ -508,13 +508,6 @@ func TestUpdateMediaItemISBN(t *testing.T) { require.NoError(t, err) defer resp.Body.Close() - assert.Equal(t, http.StatusOK, resp.StatusCode) - - var response map[string]interface{} - json.NewDecoder(resp.Body).Decode(&response) - - // Verify ISBN was normalized - assert.Equal(t, "9789876543210", response["isbn"]) - assert.Equal(t, "Updated Title", response["title"]) + assert.Equal(t, http.StatusUnprocessableEntity, resp.StatusCode) }) }