Test helpers are compiled into the shipped binary #506

Open
opened 2026-10-06 03:26:35 +02:00 by clawbot · 0 comments
Collaborator

The shared .golangci.yml that #504 vendors states that test-support code must not be compiled into the shipped binary, and its test-support depguard rule enforces that for packages a repository names in its deny list. In this repository the test helpers live in ordinary non-test files inside the production packages, so the rule cannot see them and they are built into the binary:

  • internal/config/testing.go (ClearEnvForTest), which imports testing from a non-test file;
  • internal/database/testing.go (NewTestDatabase, NewTestWebhookDBManager, NewTestWebhookDBManagerWithLogger);
  • internal/middleware/testing.go (NewForTest);
  • internal/session/testing.go (NewStore, NewForTest).

Found by the independent review of #505; out of that PR's scope.

Definition of done

  • No non-test file in a production package exists only to serve tests. Each helper moves into a _test.go file where only its own package's tests use it, or into a test-support package whose full import path is added to the test-support rule's deny list in .golangci.yml (the one list there a repository may edit).
  • Production code gains no exported constructor or field that only tests need; where a test-support package must build a value with unexported fields, the smallest plain change is chosen and disclosed.
  • Every test still exercises the same production code it did; make check and make test-browser pass.
  • Starts after #505 lands, since both change .golangci.yml.

Model: opus-5-5

The shared `.golangci.yml` that https://git.eeqj.de/sneak/webhooker/issues/504 vendors states that test-support code must not be compiled into the shipped binary, and its `test-support` `depguard` rule enforces that for packages a repository names in its deny list. In this repository the test helpers live in ordinary non-test files inside the production packages, so the rule cannot see them and they are built into the binary: - `internal/config/testing.go` (`ClearEnvForTest`), which imports `testing` from a non-test file; - `internal/database/testing.go` (`NewTestDatabase`, `NewTestWebhookDBManager`, `NewTestWebhookDBManagerWithLogger`); - `internal/middleware/testing.go` (`NewForTest`); - `internal/session/testing.go` (`NewStore`, `NewForTest`). Found by the independent review of https://git.eeqj.de/sneak/webhooker/pulls/505; out of that PR's scope. ## Definition of done - No non-test file in a production package exists only to serve tests. Each helper moves into a `_test.go` file where only its own package's tests use it, or into a test-support package whose full import path is added to the `test-support` rule's `deny` list in `.golangci.yml` (the one list there a repository may edit). - Production code gains no exported constructor or field that only tests need; where a test-support package must build a value with unexported fields, the smallest plain change is chosen and disclosed. - Every test still exercises the same production code it did; `make check` and `make test-browser` pass. - Starts after https://git.eeqj.de/sneak/webhooker/pulls/505 lands, since both change `.golangci.yml`. Model: opus-5-5
clawbot self-assigned this 2026-10-06 03:26:35 +02:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#506