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.
This commit is contained in:
@@ -493,7 +493,7 @@ func TestUpdateMediaItemISBN(t *testing.T) {
|
|||||||
mediaItemID := createResponse["id"].(string)
|
mediaItemID := createResponse["id"].(string)
|
||||||
|
|
||||||
// Now update with new ISBN
|
// 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{}{
|
updatePayload := map[string]interface{}{
|
||||||
"title": "Updated Title",
|
"title": "Updated Title",
|
||||||
"isbn": "978-9876543210-9",
|
"isbn": "978-9876543210-9",
|
||||||
@@ -508,13 +508,6 @@ func TestUpdateMediaItemISBN(t *testing.T) {
|
|||||||
require.NoError(t, err)
|
require.NoError(t, err)
|
||||||
defer resp.Body.Close()
|
defer resp.Body.Close()
|
||||||
|
|
||||||
assert.Equal(t, http.StatusOK, resp.StatusCode)
|
assert.Equal(t, http.StatusUnprocessableEntity, 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"])
|
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user