diff --git a/cmd/server/tests/analytics_test.go b/cmd/server/tests/analytics_test.go index 9b14d69..fb5c6f2 100644 --- a/cmd/server/tests/analytics_test.go +++ b/cmd/server/tests/analytics_test.go @@ -331,7 +331,7 @@ func TestAnalyticsPopularBooks(t *testing.T) { token := loginTestUser(t, ts, db) // First create a book and some reading history - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Create reading history for the book historyReq := map[string]interface{}{ diff --git a/cmd/server/tests/book_matching_test.go b/cmd/server/tests/book_matching_test.go index 257576d..3fa0622 100644 --- a/cmd/server/tests/book_matching_test.go +++ b/cmd/server/tests/book_matching_test.go @@ -38,7 +38,7 @@ func TestBookMatchingQueryBooks(t *testing.T) { defer ts.Close() token := loginTestUser(t, ts, db) - _ = createTestEbookID(t, ts, token) + _ = createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "title": "Test Ebook", @@ -180,7 +180,7 @@ func TestBookMatchingBulkLink(t *testing.T) { defer ts.Close() token := loginTestUser(t, ts, db) - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "links": []map[string]interface{}{ diff --git a/cmd/server/tests/collections_bulk_test.go b/cmd/server/tests/collections_bulk_test.go index 75cf7a3..e007be5 100644 --- a/cmd/server/tests/collections_bulk_test.go +++ b/cmd/server/tests/collections_bulk_test.go @@ -66,7 +66,7 @@ func TestCollectionsBulkOperations(t *testing.T) { defer ts.Close() token := loginTestUser(t, ts, db) - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "operations": []map[string]interface{}{ @@ -186,7 +186,7 @@ func TestCollectionsBulkOperations(t *testing.T) { collectionID := collectionResult["id"].(string) // Create a book - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Add book to collection addReq := map[string]interface{}{ @@ -249,9 +249,9 @@ func TestCollectionsBulkOperations(t *testing.T) { collectionID := collectionResult["id"].(string) // Create multiple books - bookID1 := createTestEbookID(t, ts, token) - bookID2 := createTestEbookID(t, ts, token) - bookID3 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) + bookID2 := createTestMediaItemID(t, ts, token) + bookID3 := createTestMediaItemID(t, ts, token) // Add all books to collection addReq := map[string]interface{}{ @@ -326,8 +326,8 @@ func TestCollectionsBulkOperations(t *testing.T) { collectionID2 := collectionResult2["id"].(string) // Create books - bookID1 := createTestEbookID(t, ts, token) - bookID2 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) + bookID2 := createTestMediaItemID(t, ts, token) // Add books to multiple collections addReq := map[string]interface{}{ @@ -388,7 +388,7 @@ func TestCollectionsBulkOperations(t *testing.T) { collectionID := collectionResult["id"].(string) // Create a book - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Add book to collection addReq := map[string]interface{}{ diff --git a/cmd/server/tests/kobo_test.go b/cmd/server/tests/kobo_test.go index 01b8482..5831d0a 100644 --- a/cmd/server/tests/kobo_test.go +++ b/cmd/server/tests/kobo_test.go @@ -22,7 +22,7 @@ func TestKoboInitialization(t *testing.T) { token := loginTestUser(t, ts, db) _ = getTestUserID(t, db) - _ = createTestEbookID(t, ts, token) + _ = createTestMediaItemID(t, ts, token) t.Run("successful initialization", func(t *testing.T) { req, _ := http.NewRequest("GET", ts.URL+"/api/sync/kobo/test-token/v1/initialization", nil) @@ -46,7 +46,7 @@ func TestKoboLibrarySync(t *testing.T) { defer closeTestServer(t, ts, db) token := loginTestUser(t, ts, db) - _ = createTestEbookID(t, ts, token) + _ = createTestMediaItemID(t, ts, token) t.Run("successful library sync", func(t *testing.T) { req, _ := http.NewRequest("GET", ts.URL+"/api/sync/kobo/test-token/v1/initialization", nil) @@ -70,13 +70,13 @@ func TestKoboMarkupSync(t *testing.T) { defer closeTestServer(t, ts, db) token := loginTestUser(t, ts, db) - ebookID := createTestEbookID(t, ts, token) + mediaItemID := createTestMediaItemID(t, ts, token) t.Run("successful markup sync with annotations and bookmarks", func(t *testing.T) { reqBody := map[string]interface{}{ "ReadingSync": []map[string]interface{}{ { - "ContentId": ebookID, + "ContentId": mediaItemID, "PercentRead": 45.6, "EntitlementId": "ent-123", "RemainingTimeMinutes": 120, @@ -86,14 +86,14 @@ func TestKoboMarkupSync(t *testing.T) { "BookmarkSync": []map[string]interface{}{ { "BookmarkId": "bookmark-1", - "ContentId": ebookID, + "ContentId": mediaItemID, "BookmarkText": "This is highlighted text", "BookmarkType": "annotation", "BookmarkTitle": "Chapter 3", }, { "BookmarkId": "bookmark-2", - "ContentId": ebookID, + "ContentId": mediaItemID, "BookmarkText": "This is my note abouts book", "BookmarkType": "bookmark", }, @@ -126,14 +126,14 @@ func TestKoboBookmarkSync(t *testing.T) { defer closeTestServer(t, ts, db) token := loginTestUser(t, ts, db) - ebookID := createTestEbookID(t, ts, token) + mediaItemID := createTestMediaItemID(t, ts, token) t.Run("successful bookmark sync", func(t *testing.T) { reqBody := map[string]interface{}{ "BookmarkSync": []map[string]interface{}{ { "BookmarkId": "bookmark-3", - "ContentId": ebookID, + "ContentId": mediaItemID, "BookmarkText": "Important note abouts book", "BookmarkType": "bookmark", "DateCreated": "2026-01-30T19:55:00Z", @@ -167,14 +167,14 @@ func TestKoboAnalyticsGettests(t *testing.T) { defer closeTestServer(t, ts, db) token := loginTestUser(t, ts, db) - ebookID := createTestEbookID(t, ts, token) + mediaItemID := createTestMediaItemID(t, ts, token) t.Run("successful analytics tests", func(t *testing.T) { reqBody := map[string]interface{}{ "meta": map[string]string{ "name": "Kobo Analytics Tests", }, - "ContentId": ebookID, + "ContentId": mediaItemID, "ReadingEvent": "Reading", "RemainingTimeMin": 180, "PercentRead": 67.8, diff --git a/cmd/server/tests/media_bulk_test.go b/cmd/server/tests/media_bulk_test.go index f79ce80..1cde2a6 100644 --- a/cmd/server/tests/media_bulk_test.go +++ b/cmd/server/tests/media_bulk_test.go @@ -94,8 +94,8 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, ts, db) // Create test books - bookID1 := createTestEbookID(t, ts, token) - bookID2 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) + bookID2 := createTestMediaItemID(t, ts, token) bookID3 := uuid.New().String() req := map[string]interface{}{ @@ -234,8 +234,8 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, ts, db) // Create test books - bookID1 := createTestEbookID(t, ts, token) - bookID2 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) + bookID2 := createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "book_ids": []string{bookID1, bookID2}, @@ -274,7 +274,7 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, ts, db) // Create test books - bookID1 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "book_ids": []string{bookID1}, @@ -308,7 +308,7 @@ func TestMediaBulkOperations(t *testing.T) { token := loginTestUser(t, ts, db) // Create test books - bookID1 := createTestEbookID(t, ts, token) + bookID1 := createTestMediaItemID(t, ts, token) req := map[string]interface{}{ "book_ids": []string{bookID1}, diff --git a/cmd/server/tests/opds_test.go b/cmd/server/tests/opds_test.go index be619d6..f2e7d76 100644 --- a/cmd/server/tests/opds_test.go +++ b/cmd/server/tests/opds_test.go @@ -166,7 +166,7 @@ func TestOPDSEndpoints(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/download/"+bookID, nil) httpReq.Header.Set("Authorization", "Bearer "+token) @@ -217,7 +217,7 @@ func TestOPDSEndpoints(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/cover/"+bookID, nil) httpReq.Header.Set("Authorization", "Bearer "+token) @@ -252,7 +252,7 @@ func TestOPDSEndpoints(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/formats/"+bookID, nil) httpReq.Header.Set("Authorization", "Bearer "+token) @@ -275,7 +275,7 @@ func TestOPDSConversion(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Request KEPUB format httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/download/"+bookID+"?format=kepub", nil) @@ -297,7 +297,7 @@ func TestOPDSConversion(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Request default format (no format parameter) httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/download/"+bookID, nil) @@ -318,7 +318,7 @@ func TestOPDSConversion(t *testing.T) { token := loginTestUser(t, ts, db) deviceID := uuid.New() - bookID := createTestEbookID(t, ts, token) + bookID := createTestMediaItemID(t, ts, token) // Request unsupported format httpReq, _ := http.NewRequest("GET", ts.URL+"/opds/devices/"+deviceID.String()+"/download/"+bookID+"?format=pdf", nil) diff --git a/cmd/server/tests/test_helpers.go b/cmd/server/tests/test_helpers.go index 7f316e5..b304ece 100644 --- a/cmd/server/tests/test_helpers.go +++ b/cmd/server/tests/test_helpers.go @@ -269,12 +269,12 @@ func getTestUserID(t *testing.T, db *database.Queries) uuid.UUID { return userUUID } -// createTestEbookID creates a test ebook and returns its ID -func createTestEbookID(t *testing.T, ts *httptest.Server, token string) string { +// createTestMediaItemID creates a test media item and returns its ID +func createTestMediaItemID(t *testing.T, ts *httptest.Server, token string) string { // First create a library libReq := map[string]interface{}{ "name": "Test Library", - "description": "A test library for ebooks", + "description": "A test library for media items", "type": "ebooks", } libBody, _ := json.Marshal(libReq) @@ -295,18 +295,18 @@ func createTestEbookID(t *testing.T, ts *httptest.Server, token string) string { libData := libResult["id"].(string) - // Create a test ebook - ebookReq := map[string]interface{}{ + // Create a test media item + mediaItemReq := map[string]interface{}{ "library_id": libData, - "title": "Test Ebook", + "title": "Test Media Item", "author": "Test Author", "file_path": "/tmp/test.epub", "file_size": 1024, "mime_type": "application/epub+zip", } - ebookBody, _ := json.Marshal(ebookReq) + mediaItemBody, _ := json.Marshal(mediaItemReq) - req2, _ := http.NewRequest("POST", ts.URL+"/api/media-items", bytes.NewBuffer(ebookBody)) + req2, _ := http.NewRequest("POST", ts.URL+"/api/media-items", bytes.NewBuffer(mediaItemBody)) req2.Header.Set("Content-Type", "application/json") req2.Header.Set("Authorization", "Bearer "+token) @@ -316,9 +316,9 @@ func createTestEbookID(t *testing.T, ts *httptest.Server, token string) string { require.Equal(t, http.StatusCreated, resp2.StatusCode) - var ebookResult map[string]interface{} - json.NewDecoder(resp2.Body).Decode(&ebookResult) + var mediaItemResult map[string]interface{} + json.NewDecoder(resp2.Body).Decode(&mediaItemResult) - ebookID := ebookResult["id"].(string) - return ebookID + mediaItemID := mediaItemResult["id"].(string) + return mediaItemID }