internal/globals, internal/healthcheck, and internal/logger have no tests at all #110
Reference in New Issue
Block a user
Delete Branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
REPO_POLICIES.md: "All repos with software must have tests that run via the platform-standard test framework... If no meaningful tests exist yet, add the most minimal test possible... There is no excuse formake testto be a no-op."Five packages currently have zero test files. Two of them (
internal/middleware,internal/server) will gain coverage from the HTTP hardening work in #98, #99, #100, and #101, each of which mandates tests in those packages. That leaves three genuinely uncovered:internal/globalsglobals.gointernal/healthcheckhealthcheck.gointernal/loggerlogger.gointernal/healthcheckis the one that actually matters. It backs two live HTTP routes (/healthand/.well-known/healthcheck,internal/server/routes.go:41-47) and is the endpoint an orchestrator uses to decide whether this process is alive. It is untested.Definition of done
internal/healthcheckhas real behavioural tests, not a smoke test. Cover: the response's JSON shape and field names; thatStatusis"ok"; that themaintenanceModefield reflectsConfig.MaintenanceModein both states (healthcheck.go:73); and that the version string surfaced frominternal/globalsappears in the payload (healthcheck.go:38,72).internal/globalshas a test coveringSetVersionand the version read-back. It is a tiny package — a small, honest test is the right size. Note the package-level global carries an intentional//nolint:gochecknoglobals; do not remove or relocate it to make testing easier.internal/loggerhas at least a construction test asserting a usable*slog.Loggeris returned and that the debug/non-debug configurations differ as intended. Do not assert on exact log line formatting — that is brittle. If TTY detection is not testable without contortions, test what is reachable and leave the rest alone rather than restructuring production code to chase coverage.package foo_test, table-driven where there is more than one case,t.Parallel()where safe, and anexport_test.goshim if unexported access is genuinely needed (internal/config,internal/handlers, andinternal/notifyalready do this).t.TempDir(), and none makes a network call.make checkgreen andmake testwall time stays well under the 20-second policy ceiling.TODO.mdupdated in the same commit.The finishing commit's title must end with
(closes #N)referencing this issue.Scope discipline
This is a test-only change. Do not refactor production code to make it more testable; if something is genuinely untestable without a refactor, note it in the PR description and leave it. Chasing a coverage percentage is explicitly not the goal — the goal is that these three packages stop being completely unexercised.
Sequencing
Land this after #98-#101, or at least be aware they add the
internal/middlewareandinternal/servertests. Do not duplicate their work here.