refactor: improve worker type safety and scanner reliability
Worker improvements:
- Add strongly-typed result structs for all job types
- Replace map[string]interface{} with specific result types
- Add JSON tags to JobResult for proper API serialization
- Fix processJob to handle different result types correctly
- Improve directory scan job with proper library folder resolution
- Add debug logging for scan operations
Media scanner improvements:
- Add nil checks for database in GetPollInterval and GetAutoScanEnabled
- Fix pdfcpu API call signature (add validateOnly parameter)
- Add debug logging for scanDirectory with file counters
- Improve error handling and reporting
Test fixes:
- Fix default poll interval expectation from 30s to 60s
- Add settingsCache initialization to scanner tests
- Add folders initialization to ProcessDirtyDirectories test
This commit is contained in:
@@ -7,17 +7,23 @@ import (
|
||||
|
||||
func TestMediaScanner_GetPollInterval(t *testing.T) {
|
||||
t.Run("nil db returns default", func(t *testing.T) {
|
||||
scanner := &MediaScanner{db: nil}
|
||||
scanner := &MediaScanner{
|
||||
db: nil,
|
||||
settingsCache: NewSettingsCache(30 * time.Second),
|
||||
}
|
||||
interval := scanner.GetPollInterval()
|
||||
if interval != 30*time.Second {
|
||||
t.Errorf("expected 30s, got %v", interval)
|
||||
if interval != 60*time.Second {
|
||||
t.Errorf("expected 60s, got %v", interval)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
func TestMediaScanner_GetAutoScanEnabled(t *testing.T) {
|
||||
t.Run("nil db returns default true", func(t *testing.T) {
|
||||
scanner := &MediaScanner{db: nil}
|
||||
scanner := &MediaScanner{
|
||||
db: nil,
|
||||
settingsCache: NewSettingsCache(30 * time.Second),
|
||||
}
|
||||
enabled := scanner.GetAutoScanEnabled()
|
||||
if enabled != true {
|
||||
t.Errorf("expected true, got %v", enabled)
|
||||
|
||||
Reference in New Issue
Block a user