Config package has only 23% test coverage #72

Closed
opened 2026-03-02 00:51:27 +01:00 by clawbot · 1 comment
Collaborator

Problem

The internal/config package has 23% test coverage. Only ClassifyTargets() and related PSL logic are tested. The main configuration loading path is untested.

What is Untested

  • New() — the main config constructor
  • buildConfig() — reading from Viper, interval parsing, fallback defaults
  • setupViper() — env prefix binding, default values
  • parseCSV() — CSV string parsing
  • configureDebugLogging() — debug mode activation
  • StatePath() — path construction
  • Invalid interval strings (e.g., DNSWATCHER_DNS_INTERVAL=banana)
  • Config file loading and precedence

Why This Matters

Configuration is the user's primary interface to the daemon. Untested config paths mean:

  • Silent fallback to defaults on typos
  • Potentially accepting invalid values without warning
  • Undiscovered parsing edge cases

Recommendation

Add tests covering:

  1. Default values are correct
  2. Environment variable overrides work
  3. Invalid duration strings fall back to defaults (and ideally warn)
  4. parseCSV edge cases (trailing commas, whitespace, empty strings)
  5. StatePath returns expected path

Category

Nice-to-have for 1.0. The config code is simple and works correctly in practice, but should be tested before claiming production readiness.

## Problem The `internal/config` package has **23% test coverage**. Only `ClassifyTargets()` and related PSL logic are tested. The main configuration loading path is untested. ## What is Untested - `New()` — the main config constructor - `buildConfig()` — reading from Viper, interval parsing, fallback defaults - `setupViper()` — env prefix binding, default values - `parseCSV()` — CSV string parsing - `configureDebugLogging()` — debug mode activation - `StatePath()` — path construction - Invalid interval strings (e.g., `DNSWATCHER_DNS_INTERVAL=banana`) - Config file loading and precedence ## Why This Matters Configuration is the user's primary interface to the daemon. Untested config paths mean: - Silent fallback to defaults on typos - Potentially accepting invalid values without warning - Undiscovered parsing edge cases ## Recommendation Add tests covering: 1. Default values are correct 2. Environment variable overrides work 3. Invalid duration strings fall back to defaults (and ideally warn) 4. `parseCSV` edge cases (trailing commas, whitespace, empty strings) 5. `StatePath` returns expected path ## Category Nice-to-have for 1.0. The config code is simple and works correctly in practice, but should be tested before claiming production readiness.
clawbot added the bot label 2026-03-02 00:51:27 +01:00
Author
Collaborator

Closing: completed by PR #81 (merged).

Closing: completed by [PR #81](https://git.eeqj.de/sneak/dnswatcher/pulls/81) (merged).
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/dnswatcher#72