test: update test signatures to match new test_helpers.go
- Remove handler parameter from test function calls - Update test signatures to use new return values from setupTestServer - Fix compilation errors after test helper refactoring - Maintain test functionality while simplifying setup
This commit is contained in:
@@ -14,7 +14,7 @@ import (
|
||||
// TestAnalyticsReadingStats tests the reading statistics endpoint
|
||||
func TestAnalyticsReadingStats(t *testing.T) {
|
||||
t.Run("GetReadingStats_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", ts.URL+"/api/analytics/reading-stats", nil)
|
||||
@@ -27,7 +27,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetReadingStats_WithAuth_DefaultDates", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -53,7 +53,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetReadingStats_WithCustomDateRange", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -72,7 +72,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetReadingStats_InvalidStartDate", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -88,7 +88,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetReadingStats_InvalidEndDate", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -104,7 +104,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetReadingStats_EmptyHistory", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -130,7 +130,7 @@ func TestAnalyticsReadingStats(t *testing.T) {
|
||||
// TestAnalyticsDeviceUsage tests the device usage endpoint
|
||||
func TestAnalyticsDeviceUsage(t *testing.T) {
|
||||
t.Run("GetDeviceUsage_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", ts.URL+"/api/analytics/device-usage", nil)
|
||||
@@ -143,7 +143,7 @@ func TestAnalyticsDeviceUsage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetDeviceUsage_WithAuth_NoDevices", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -166,7 +166,7 @@ func TestAnalyticsDeviceUsage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetDeviceUsage_WithAuth_WithDevices", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -206,7 +206,7 @@ func TestAnalyticsDeviceUsage(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetDeviceUsage_ResponseStructure", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -242,7 +242,7 @@ func TestAnalyticsDeviceUsage(t *testing.T) {
|
||||
// TestAnalyticsPopularBooks tests the popular books endpoint
|
||||
func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
t.Run("GetPopularBooks_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req, _ := http.NewRequest("GET", ts.URL+"/api/analytics/popular-books", nil)
|
||||
@@ -255,7 +255,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetPopularBooks_WithAuth_DefaultLimit", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -280,7 +280,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetPopularBooks_WithCustomLimit", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -302,7 +302,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetPopularBooks_InvalidLimit", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -325,7 +325,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetPopularBooks_ResponseStructure", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -378,7 +378,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetPopularBooks_NoReadingHistory", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -404,7 +404,7 @@ func TestAnalyticsPopularBooks(t *testing.T) {
|
||||
// TestAnalyticsEdgeCases tests edge cases for analytics endpoints
|
||||
func TestAnalyticsEdgeCases(t *testing.T) {
|
||||
t.Run("ReadingStats_FutureDateRange", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -429,7 +429,7 @@ func TestAnalyticsEdgeCases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("PopularBooks_LimitZero", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -452,7 +452,7 @@ func TestAnalyticsEdgeCases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("PopularBooks_VeryLargeLimit", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
|
||||
@@ -11,10 +11,28 @@ import (
|
||||
"github.com/stretchr/testify/require"
|
||||
)
|
||||
|
||||
// getJSONInt converts an interface{} value to int, handling both int and float64
|
||||
func getJSONInt(v interface{}) int {
|
||||
switch val := v.(type) {
|
||||
case int:
|
||||
return val
|
||||
case float64:
|
||||
return int(val)
|
||||
case int32:
|
||||
return int(val)
|
||||
case int64:
|
||||
return int(val)
|
||||
case float32:
|
||||
return int(val)
|
||||
default:
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
// TestBookMatchingQueryBooks tests the book query endpoint
|
||||
func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
t.Run("QueryBooks_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req := map[string]interface{}{
|
||||
@@ -34,7 +52,7 @@ func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("QueryBooks_WithAuth_ByTitle", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -64,7 +82,7 @@ func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("QueryBooks_InvalidRequestBody", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -83,7 +101,7 @@ func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("QueryBooks_NoResults", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -107,7 +125,12 @@ func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
var result map[string]interface{}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
|
||||
matches := result["matches"].([]interface{})
|
||||
var matches []interface{}
|
||||
if matchesIf, ok := result["matches"]; ok && matchesIf != nil {
|
||||
if matchesSlice, ok := matchesIf.([]interface{}); ok {
|
||||
matches = matchesSlice
|
||||
}
|
||||
}
|
||||
assert.Equal(t, 0, len(matches))
|
||||
})
|
||||
}
|
||||
@@ -115,7 +138,7 @@ func TestBookMatchingQueryBooks(t *testing.T) {
|
||||
// TestBookMatchingBulkLink tests bulk linking operations
|
||||
func TestBookMatchingBulkLink(t *testing.T) {
|
||||
t.Run("BulkLinkBooks_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req := map[string]interface{}{
|
||||
@@ -141,7 +164,7 @@ func TestBookMatchingBulkLink(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkLinkBooks_WithAuth_EmptyLinks", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -165,13 +188,13 @@ func TestBookMatchingBulkLink(t *testing.T) {
|
||||
var result map[string]interface{}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
|
||||
assert.Equal(t, 0, result["total"])
|
||||
assert.Equal(t, 0, result["successful"])
|
||||
assert.Equal(t, 0, result["failed"])
|
||||
assert.Equal(t, 0, getJSONInt(result["total"]))
|
||||
assert.Equal(t, 0, getJSONInt(result["successful"]))
|
||||
assert.Equal(t, 0, getJSONInt(result["failed"]))
|
||||
})
|
||||
|
||||
t.Run("BulkLinkBooks_InvalidUnlinkedBookID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -213,7 +236,7 @@ func TestBookMatchingBulkLink(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkLinkBooks_MultipleLinks", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -253,7 +276,7 @@ func TestBookMatchingBulkLink(t *testing.T) {
|
||||
var result map[string]interface{}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
|
||||
assert.Equal(t, 3, result["total"])
|
||||
assert.Equal(t, 3, getJSONInt(result["total"]))
|
||||
results := result["results"].([]interface{})
|
||||
assert.Equal(t, 3, len(results))
|
||||
})
|
||||
@@ -262,7 +285,7 @@ func TestBookMatchingBulkLink(t *testing.T) {
|
||||
// TestBookMatchingAutoLink tests automatic linking
|
||||
func TestBookMatchingAutoLink(t *testing.T) {
|
||||
t.Run("AutoLinkBooks_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req := map[string]interface{}{
|
||||
@@ -283,7 +306,7 @@ func TestBookMatchingAutoLink(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("AutoLinkBooks_WithAuth_DefaultThreshold", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -310,7 +333,7 @@ func TestBookMatchingAutoLink(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("AutoLinkBooks_CustomThreshold", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -339,7 +362,7 @@ func TestBookMatchingAutoLink(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("AutoLinkBooks_NoUnlinkedBooks", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -371,7 +394,7 @@ func TestBookMatchingAutoLink(t *testing.T) {
|
||||
// TestBookMatchingSuggestions tests getting suggestions for unlinked books
|
||||
func TestBookMatchingSuggestions(t *testing.T) {
|
||||
t.Run("GetUnlinkedBookSuggestions_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
testID := uuid.New()
|
||||
@@ -386,7 +409,7 @@ func TestBookMatchingSuggestions(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetUnlinkedBookSuggestions_InvalidUUID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -403,7 +426,7 @@ func TestBookMatchingSuggestions(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetUnlinkedBookSuggestions_BookNotFound", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -421,7 +444,7 @@ func TestBookMatchingSuggestions(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetUnlinkedBookSuggestions_ResponseStructure", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -445,7 +468,7 @@ func TestBookMatchingSuggestions(t *testing.T) {
|
||||
// TestBookMatchingDeviceFileAliases tests device file alias operations
|
||||
func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
t.Run("GetDeviceFileAliases_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
testID := uuid.New()
|
||||
@@ -460,7 +483,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetDeviceFileAliases_WithAuth", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -485,7 +508,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("CreateDeviceFileAlias_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
deviceID := uuid.New()
|
||||
@@ -511,7 +534,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("CreateDeviceFileAlias_InvalidDeviceID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -539,7 +562,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("CreateDeviceFileAlias_InvalidMediaItemID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -567,7 +590,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("UpdateDeviceFileAlias_InvalidAliasID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -592,7 +615,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("DeleteDeviceFileAlias_InvalidAliasID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -614,7 +637,7 @@ func TestBookMatchingDeviceFileAliases(t *testing.T) {
|
||||
// TestBookMatchingGetBookMatches tests the book matches endpoint
|
||||
func TestBookMatchingGetBookMatches(t *testing.T) {
|
||||
t.Run("GetBookMatches_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
httpReq, _ := http.NewRequest("GET", ts.URL+"/api/books/match?title=Test", nil)
|
||||
@@ -628,7 +651,7 @@ func TestBookMatchingGetBookMatches(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetBookMatches_WithAuth_ByTitle", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -651,7 +674,7 @@ func TestBookMatchingGetBookMatches(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetBookMatches_InvalidFileSize", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -668,7 +691,7 @@ func TestBookMatchingGetBookMatches(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("GetBookMatches_MultipleIdentifiers", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
|
||||
@@ -14,7 +14,7 @@ import (
|
||||
// TestCollectionsBulkOperations tests bulk collection operations
|
||||
func TestCollectionsBulkOperations(t *testing.T) {
|
||||
t.Run("BulkAddBooks_WithoutAuth", func(t *testing.T) {
|
||||
ts, _, _, _ := setupTestServer(t)
|
||||
ts, _, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
req := map[string]interface{}{
|
||||
@@ -39,7 +39,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_EmptyOperations", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -62,7 +62,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_InvalidCollectionID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -105,7 +105,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_InvalidBookID", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -160,7 +160,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_SingleOperation", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -223,7 +223,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_MultipleBooksSingleCollection", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -277,12 +277,12 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
var result map[string]interface{}
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
|
||||
assert.Equal(t, 3, result["total"])
|
||||
assert.Equal(t, 3, getJSONInt(result["total"]))
|
||||
assert.True(t, result["success"].(float64) > 0)
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_MultipleCollections", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -358,11 +358,11 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
json.NewDecoder(resp.Body).Decode(&result)
|
||||
|
||||
assert.Contains(t, result, "results")
|
||||
assert.Equal(t, 3, result["total"])
|
||||
assert.Equal(t, 3, getJSONInt(result["total"]))
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_DuplicateBooks", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
@@ -419,7 +419,7 @@ func TestCollectionsBulkOperations(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("BulkAddBooks_InvalidRequestBody", func(t *testing.T) {
|
||||
ts, db, _, _ := setupTestServer(t)
|
||||
ts, db, _ := setupTestServer(t)
|
||||
defer ts.Close()
|
||||
|
||||
token := loginTestUser(t, ts, db)
|
||||
|
||||
Reference in New Issue
Block a user