test(config): add comprehensive tests for config loading path #81

Merged
sneak merged 1 commits from fix/72-config-test-coverage into main 2026-03-04 11:23:25 +01:00

1 Commits

Author SHA1 Message Date
user
0219d7e6e1 test(config): add comprehensive tests for config loading path
All checks were successful
check / check (push) Successful in 43s
Add tests covering the main configuration loading path which was
previously untested (only ClassifyTargets and PSL logic had tests).

New test coverage:
- New() constructor with default values, env overrides, and error cases
- buildConfig() interval parsing with fallback to defaults on invalid input
- setupViper() env prefix binding and default value registration
- parseCSV() edge cases: whitespace, trailing/leading commas, empty segments
- configureDebugLogging() debug mode activation
- StatePath() path construction with various DataDir values
- ErrNoTargets sentinel error for missing/empty targets
- PORT env without DNSWATCHER_ prefix (compatibility)
- Target classification into domains vs hostnames via PSL
- Invalid targets (public suffixes) rejected with clear error

Coverage for internal/config increased from 23% to 92.5%.
2026-03-01 23:56:21 -08:00