Tests outside the config package still read the developer's shell when they build a Config #452

Closed
opened 2026-10-02 17:44:42 +02:00 by clawbot · 1 comment
Collaborator

TestNewApp_SendsFxEventsToTheLogger in cmd/webhooker/main_test.go (from #443) builds a Config without clearing the environment, so a variable exported in the developer's shell changes its result: a METRICS_USERNAME without METRICS_PASSWORD fails it. Found by the review of #444, which added config.ClearEnvForTest for exactly this.

Definition of done

  • Every test outside internal/config that builds a Config through config.New calls config.ClearEnvForTest before setting its own variables.
  • Nothing else changes.

Model: opus-5-5

`TestNewApp_SendsFxEventsToTheLogger` in `cmd/webhooker/main_test.go` (from https://git.eeqj.de/sneak/webhooker/pulls/443) builds a Config without clearing the environment, so a variable exported in the developer's shell changes its result: a `METRICS_USERNAME` without `METRICS_PASSWORD` fails it. Found by the review of https://git.eeqj.de/sneak/webhooker/pulls/444, which added `config.ClearEnvForTest` for exactly this. ## Definition of done - Every test outside `internal/config` that builds a Config through `config.New` calls `config.ClearEnvForTest` before setting its own variables. - Nothing else changes. Model: opus-5-5
Author
Collaborator

#453 makes the two tests in cmd/webhooker/main_test.go that build the app graph (TestNewApp_StopTimeout and TestNewApp_SendsFxEventsToTheLogger) call config.ClearEnvForTest before setting their own variables. The first-boot test in internal/gormlog already did; no other test outside internal/config builds a Config through config.New.

Judgement call: TestNewApp_StopTimeout is included although its result does not depend on the shell, because it does run config.New.

Model: opus-5-5

https://git.eeqj.de/sneak/webhooker/pulls/453 makes the two tests in `cmd/webhooker/main_test.go` that build the app graph (`TestNewApp_StopTimeout` and `TestNewApp_SendsFxEventsToTheLogger`) call `config.ClearEnvForTest` before setting their own variables. The first-boot test in `internal/gormlog` already did; no other test outside `internal/config` builds a Config through `config.New`. Judgement call: `TestNewApp_StopTimeout` is included although its result does not depend on the shell, because it does run `config.New`. Model: opus-5-5
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: sneak/webhooker#452