diff --git a/cmd/server/tests/media_bulk_test.go b/cmd/server/tests/media_bulk_test.go index 175de98..850079d 100644 --- a/cmd/server/tests/media_bulk_test.go +++ b/cmd/server/tests/media_bulk_test.go @@ -17,11 +17,11 @@ func TestMediaBulkOperations(t *testing.T) { setup := setupTestServer(t) req := map[string]interface{}{ - "book_ids": []string{uuid.New().String()}, + "media_item_ids": []string{uuid.New().String()}, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-delete", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-delete", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") client := &http.Client{} @@ -38,11 +38,11 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) req := map[string]interface{}{ - "book_ids": []string{}, + "media_item_ids": []string{}, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-delete", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-delete", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -60,11 +60,11 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) req := map[string]interface{}{ - "book_ids": []string{"invalid-uuid", "another-invalid"}, + "media_item_ids": []string{"invalid-uuid", "another-invalid"}, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-delete", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-delete", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -89,17 +89,17 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) - // Create test books - bookID1 := createTestMediaItemID(t, setup.Server, token) - bookID2 := createTestMediaItemID(t, setup.Server, token) - bookID3 := uuid.New().String() + // Create test media items + mediaID1 := createTestMediaItemID(t, setup.Server, token) + mediaID2 := createTestMediaItemID(t, setup.Server, token) + mediaID3 := uuid.New().String() req := map[string]interface{}{ - "book_ids": []string{bookID1, bookID2, bookID3}, + "media_item_ids": []string{mediaID1, mediaID2, mediaID3}, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-delete", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-delete", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -127,7 +127,7 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) // Send invalid JSON - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-delete", bytes.NewBuffer([]byte("invalid json"))) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-delete", bytes.NewBuffer([]byte("invalid json"))) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -143,14 +143,18 @@ func TestMediaBulkOperations(t *testing.T) { setup := setupTestServer(t) req := map[string]interface{}{ - "book_ids": []string{uuid.New().String()}, - "updates": map[string]interface{}{ - "tags": []string{"test"}, + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": uuid.New().String(), + "updates": map[string]interface{}{ + "tags": []string{"test"}, + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") client := &http.Client{} @@ -167,14 +171,18 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) req := map[string]interface{}{ - "book_ids": []string{}, - "updates": map[string]interface{}{ - "tags": []string{"test"}, + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": "", + "updates": map[string]interface{}{ + "tags": []string{"test"}, + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -192,14 +200,18 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) req := map[string]interface{}{ - "book_ids": []string{"invalid-uuid"}, - "updates": map[string]interface{}{ - "tags": []string{"fiction", "test"}, + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": "invalid-uuid", + "updates": map[string]interface{}{ + "tags": []string{"fiction", "test"}, + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -224,19 +236,29 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) - // Create test books - bookID1 := createTestMediaItemID(t, setup.Server, token) - bookID2 := createTestMediaItemID(t, setup.Server, token) + // Create test media items + mediaID1 := createTestMediaItemID(t, setup.Server, token) + mediaID2 := createTestMediaItemID(t, setup.Server, token) req := map[string]interface{}{ - "book_ids": []string{bookID1, bookID2}, - "updates": map[string]interface{}{ - "tags": []string{"fiction", "science-fiction", "test"}, + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": mediaID1, + "updates": map[string]interface{}{ + "tags": []string{"fiction", "science-fiction", "test"}, + }, + }, + { + "media_item_id": mediaID2, + "updates": map[string]interface{}{ + "tags": []string{"fiction", "science-fiction", "test"}, + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -263,18 +285,22 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) - // Create test books - bookID1 := createTestMediaItemID(t, setup.Server, token) + // Create test media items + mediaID1 := createTestMediaItemID(t, setup.Server, token) req := map[string]interface{}{ - "book_ids": []string{bookID1}, - "updates": map[string]interface{}{ - "reading_status": "reading", + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": mediaID1, + "updates": map[string]interface{}{ + "reading_status": "reading", + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -296,20 +322,24 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) - // Create test books - bookID1 := createTestMediaItemID(t, setup.Server, token) + // Create test media items + mediaID1 := createTestMediaItemID(t, setup.Server, token) req := map[string]interface{}{ - "book_ids": []string{bookID1}, - "updates": map[string]interface{}{ - "tags": []string{"test", "bulk-update"}, - "reading_status": "to-read", - "rating": 4, + "media_item_updates": []map[string]interface{}{ + { + "media_item_id": mediaID1, + "updates": map[string]interface{}{ + "tags": []string{"test", "bulk-update"}, + "reading_status": "to-read", + "rating": 4, + }, + }, }, } body, _ := json.Marshal(req) - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer(body)) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer(body)) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token) @@ -332,7 +362,7 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, setup.Server, setup.DB) // Send invalid JSON - httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/books/bulk-update", bytes.NewBuffer([]byte("invalid json"))) + httpReq, _ := http.NewRequest("POST", setup.Server.URL+"/api/media-items/bulk-update", bytes.NewBuffer([]byte("invalid json"))) httpReq.Header.Set("Content-Type", "application/json") httpReq.Header.Set("Authorization", "Bearer "+token)