Add tests for globals, healthcheck, and logger packages #154

Merged
clawbot merged 1 commits from issue-110-tests-globals-healthcheck-logger into next 2026-09-21 10:05:39 +02:00
Collaborator

Closes #110.

internal/globals, internal/healthcheck, and internal/logger had no
tests. This adds behavioural, external (package foo_test) tests only; no
production code changed.

What each covers, chosen so a plausible break turns the test red:

  • globals: the setters and read-back through New, and that New returns
    an independent snapshot (a later SetVersion must not mutate a Globals
    handed out earlier).
  • healthcheck: Check returns Status "ok", marshals to exactly the
    documented JSON field set (a renamed tag fails it), emits an
    RFC3339Nano now, mirrors Config.MaintenanceMode in both states, and
    surfaces the version and appname from globals. Built through the real
    constructor via a minimal recording fx.Lifecycle, running the
    registered OnStart hook so StartupTime is set the normal way.
  • logger: New yields a usable *slog.Logger; debug is suppressed at the
    default level and EnableDebugLogging turns it on (asserted via
    Logger.Enabled, not log-line formatting).

What a reader should know:

  • The globals test is one sequential function carrying
    //nolint:paralleltest, because it mutates shared package-level
    globals and so cannot run with t.Parallel(). Disclosure: one lint
    suppression, with a reason comment.
  • Judgement call: the TTY-vs-JSON handler branch in logger is not
    asserted; exercising it would mean restructuring production code, which
    the issue forbids.

make check is green; no filesystem writes outside process temp and no
network calls.

Model: opus-4-8

Closes https://git.eeqj.de/sneak/dnswatcher/issues/110. `internal/globals`, `internal/healthcheck`, and `internal/logger` had no tests. This adds behavioural, external (`package foo_test`) tests only; no production code changed. What each covers, chosen so a plausible break turns the test red: - globals: the setters and read-back through `New`, and that `New` returns an independent snapshot (a later `SetVersion` must not mutate a `Globals` handed out earlier). - healthcheck: `Check` returns `Status` `"ok"`, marshals to exactly the documented JSON field set (a renamed tag fails it), emits an RFC3339Nano `now`, mirrors `Config.MaintenanceMode` in both states, and surfaces the version and appname from globals. Built through the real constructor via a minimal recording `fx.Lifecycle`, running the registered `OnStart` hook so `StartupTime` is set the normal way. - logger: `New` yields a usable `*slog.Logger`; debug is suppressed at the default level and `EnableDebugLogging` turns it on (asserted via `Logger.Enabled`, not log-line formatting). What a reader should know: - The globals test is one sequential function carrying `//nolint:paralleltest`, because it mutates shared package-level globals and so cannot run with `t.Parallel()`. Disclosure: one lint suppression, with a reason comment. - Judgement call: the TTY-vs-JSON handler branch in `logger` is not asserted; exercising it would mean restructuring production code, which the issue forbids. `make check` is green; no filesystem writes outside process temp and no network calls. Model: opus-4-8
clawbot added 1 commit 2026-09-21 09:57:08 +02:00
These three packages had no tests. Add behavioural, external
(package foo_test) tests that can each fail on a plausible break:

- globals: setters and read-back through New, plus that New returns
  an independent snapshot. One sequential function with a disclosed
  paralleltest suppression, because it mutates shared package globals.
- healthcheck: Check returns status "ok", the exact documented JSON
  field set, an RFC3339Nano timestamp, maintenanceMode mirroring the
  config in both states, and the version and appname from globals.
- logger: New yields a usable *slog.Logger, debug is suppressed at the
  default level, and EnableDebugLogging turns it on.

No production code changed. TTY-branch output format is not asserted.

Model: opus-4-8
clawbot added the needs-review label 2026-09-21 09:57:17 +02:00
clawbot self-assigned this 2026-09-21 09:57:17 +02:00
Author
Collaborator

Review: PASS at 218abb4

Model: opus-4-8

Review: PASS at 218abb4 Model: opus-4-8
clawbot merged commit c2a07ce690 into next 2026-09-21 10:05:39 +02:00
clawbot deleted branch issue-110-tests-globals-healthcheck-logger 2026-09-21 10:05:39 +02:00
Sign in to join this conversation.