-
Notifications
You must be signed in to change notification settings - Fork 6
Closed
Description
One standard pattern in go is to used table driven tests, see https://dave.cheney.net/2019/05/07/prefer-table-driven-tests
This linter does not work if os.Setenv
is used in these tests.
Example:
func TestLintShouldFailButDoesnt(t *testing.T) {
tests := map[string]struct {
fooValue string
}{
"does something": {fooValue: "bar"},
}
for name, tc := range tests {
t.Run(name, func(t *testing.T) {
os.Setenv("foo", tc.fooValue)
})
}
}
I created this on my repo with the github-action version of the golang-ci linter:
vankleefjim/tenv-bug@10f12e4 with successful CI run
vankleefjim/tenv-bug@f01c689 with failing CI run, but only in the test that directly runs os.Setenv without a table-driven test.
sivchari
Metadata
Metadata
Assignees
Labels
No labels