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
This commit is contained in:
2026-03-24 21:13:43 -04:00
parent c00fb89962
commit 3af3fd180f
+7
View File
@@ -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