Follow-ups from the PR #92 review: config test hygiene and env docs #94
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?
Tracking issue for the non-blocking nits raised in the independent review of PR #92 (#80), so they do not become untracked. None blocked that merge.
Items
os.Unsetenvwithout restore.internal/config/env_test.gocallsos.Unsetenvdirectly to simulate an unset variable. Unliket.Setenv, that does not restore the prior value at test end, so it leaks unset state into later tests in the same binary. It exactly mirrors the pre-existing pattern ininternal/config/config_test.go, which is why it was not a blocker. Fix both: capture and restore viat.Cleanup, or add a small helper that does.config.Newtests do not neutralise ambient environment. Theconfig.New-level tests set only the variable under test. A developer with, say,DEBUGorPORTexported in their shell (or a.envfile — notegodotenv/autoloadis imported by the config package) could get different results locally than CI. Explicitly clear the full set of variables the config reads at the start of those tests.TestEnvPorterror assertions are weaker than its siblings. The other helper tables assert the offending value appears in the error message; theenvPorterror branch only checks the sentinel viaerrors.Is. Make it consistent — the whole point of #80 is that the operator can see which key and which value were wrong.ErrInvalidPortcovers only the above-range case. Below-range values (0, negatives) surface asErrNonPositiveValuefrom the innerenvPositiveInt. Both correctly abort startup, so this is cosmetic, but a caller matching onErrInvalidPortto mean "bad port" will miss half the bad ports. Either route both bounds throughErrInvalidPortor document the split.README.md(~line 104) citesRETENTION_SWEEP_INTERVALin prose but the variable is absent from the configuration table. Add it, with its default and the note that a set-but-unparseable value aborts startup.Definition of done
make checkgreen via the repo's own entrypoints;.golangci.ymluntouched.