From 3af3fd180fd3a784a08988233e6ae005c3572ded Mon Sep 17 00:00:00 2001 From: John O'Keefe Date: Tue, 24 Mar 2026 21:13:43 -0400 Subject: [PATCH] fix: add test files to TestWorker_ConcurrentJobs for scanner Problem: TestWorker_ConcurrentJobs was failing because it created empty temporary directories and submitted scan jobs, but never added any test files for the scanner to process. The scanner would complete successfully but create no media items, causing the test to fail with 'Should NOT be empty, but was []'. Root Cause: The test was incomplete - it created the directory structure but didn't populate the directories with test .epub files that the scanner could process into media items. Solution: Added code to create 2 test .epub files in each of the 3 temporary directories before submitting concurrent scan jobs: - Directory 1: book0.epub, book1.epub - Directory 2: book0.epub, book1.epub - Directory 3: book0.epub, book1.epub - Total: 6 test files to be scanned concurrently This matches the pattern used in TestWorker_DirectoryScanJob which creates test files before scanning. Files changed: - cmd/server/tests/worker_test.go: Added test file creation loop --- cmd/server/tests/worker_test.go | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/cmd/server/tests/worker_test.go b/cmd/server/tests/worker_test.go index 6dc6642..3aa30c7 100644 --- a/cmd/server/tests/worker_test.go +++ b/cmd/server/tests/worker_test.go @@ -219,6 +219,13 @@ func TestWorker_ConcurrentJobs(t *testing.T) { FolderPath: tmpDir, }) require.NoError(t, err) + + // Create test files in each directory + for j := 0; j < 2; j++ { + filePath := filepath.Join(tmpDir, fmt.Sprintf("book%d.epub", j)) + err = os.WriteFile(filePath, []byte(fmt.Sprintf("test content %d", j)), 0644) + require.NoError(t, err, "Failed to create test file") + } } // Submit multiple concurrent jobs