refactor(tests): update test helpers and all test file references

- Rename createTestEbookID to createTestMediaItemID in test_helpers.go
- Update test helper comments and variable names (ebookReq -> mediaItemReq, etc.)
- Update all test file references:
  - analytics_test.go
  - book_matching_test.go
  - collections_bulk_test.go
  - kobo_test.go
  - media_bulk_test.go
  - opds_test.go
- Rename ebookID variable to mediaItemID in kobo_test.go
- Update test data to use 'Test Media Item' instead of 'Test Ebook'
This commit is contained in:
2026-02-08 14:32:37 -05:00
parent a9e0b33002
commit 38acc46988
7 changed files with 45 additions and 45 deletions
+12 -12
View File
@@ -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
}