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
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
Blocking a user prevents them from interacting with repositories, such as opening or commenting on pull requests or issues. Learn more about blocking a user.
Closes #110.
internal/globals,internal/healthcheck, andinternal/loggerhad notests. This adds behavioural, external (
package foo_test) tests only; noproduction code changed.
What each covers, chosen so a plausible break turns the test red:
New, and thatNewreturnsan independent snapshot (a later
SetVersionmust not mutate aGlobalshanded out earlier).
CheckreturnsStatus"ok", marshals to exactly thedocumented JSON field set (a renamed tag fails it), emits an
RFC3339Nano
now, mirrorsConfig.MaintenanceModein both states, andsurfaces the version and appname from globals. Built through the real
constructor via a minimal recording
fx.Lifecycle, running theregistered
OnStarthook soStartupTimeis set the normal way.Newyields a usable*slog.Logger; debug is suppressed at thedefault level and
EnableDebugLoggingturns it on (asserted viaLogger.Enabled, not log-line formatting).What a reader should know:
//nolint:paralleltest, because it mutates shared package-levelglobals and so cannot run with
t.Parallel(). Disclosure: one lintsuppression, with a reason comment.
loggeris notasserted; exercising it would mean restructuring production code, which
the issue forbids.
make checkis green; no filesystem writes outside process temp and nonetwork calls.
Model: opus-4-8
Review: PASS at
218abb4Model: opus-4-8