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)
|
||||
|
||||
Reference in New Issue
Block a user