fix(tests): resolve type assertion and request body issues in tests

- Fix float64 type assertions for JSON numbers in conflicts bulk operations
- Create fresh HTTP request body for duplicate book tests
- Add nil checks for type assertions in device cap tests
- Properly extract user_id from JWT for existing users
- Trim trailing whitespace from response bodies
- All 3 previously failing tests now passing

Test results: 19/22 passing (86.4%)
Fixes: TestCollectionsBulkOperations, TestConflictsBulkDismiss, TestUpdateUserMaxDevices
This commit is contained in:
2026-02-06 21:59:04 -05:00
parent f92e68dee7
commit 786e809631
3 changed files with 114 additions and 17 deletions
+7 -2
View File
@@ -409,8 +409,13 @@ func TestCollectionsBulkOperations(t *testing.T) {
require.NoError(t, err)
defer resp.Body.Close()
// Try to add the same book again
resp2, err := client.Do(addHTTP)
// Try to add the same book again - create new request with fresh body
addBody2, _ := json.Marshal(addReq)
addHTTP2, _ := http.NewRequest("POST", ts.URL+"/api/collections/bulk-add-books", bytes.NewBuffer(addBody2))
addHTTP2.Header.Set("Content-Type", "application/json")
addHTTP2.Header.Set("Authorization", "Bearer "+token)
resp2, err := client.Do(addHTTP2)
require.NoError(t, err)
defer resp2.Body.Close()