Files
bookhoard/internal/services/media_scanner_settings_test.go
T
john-okeefe bb0158e8fb 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
2026-03-06 01:52:42 -05:00

33 lines
743 B
Go

package services
import (
"testing"
"time"
)
func TestMediaScanner_GetPollInterval(t *testing.T) {
t.Run("nil db returns default", func(t *testing.T) {
scanner := &MediaScanner{
db: nil,
settingsCache: NewSettingsCache(30 * time.Second),
}
interval := scanner.GetPollInterval()
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,
settingsCache: NewSettingsCache(30 * time.Second),
}
enabled := scanner.GetAutoScanEnabled()
if enabled != true {
t.Errorf("expected true, got %v", enabled)
}
})
}