ci: enable the usetesting linter (#5222)

This linter is useful to detect the creation of temporary directories
and the setting of environment variables in tests.
This commit is contained in:
Marten Seemann
2025-06-11 15:39:07 +08:00
committed by GitHub
parent aa22706d78
commit d33d293fd2
3 changed files with 11 additions and 16 deletions

View File

@@ -123,8 +123,6 @@ func TestLogAddPrefixes(t *testing.T) {
}
func TestLogLevelFromEnv(t *testing.T) {
defer os.Unsetenv(logEnv)
testCases := []struct {
envValue string
expected LogLevel
@@ -136,13 +134,13 @@ func TestLogLevelFromEnv(t *testing.T) {
}
for _, tc := range testCases {
os.Setenv(logEnv, tc.envValue)
t.Setenv(logEnv, tc.envValue)
require.Equal(t, tc.expected, readLoggingEnv())
}
// invalid values
os.Setenv(logEnv, "")
t.Setenv(logEnv, "")
require.Equal(t, LogLevelNothing, readLoggingEnv())
os.Setenv(logEnv, "asdf")
t.Setenv(logEnv, "asdf")
require.Equal(t, LogLevelNothing, readLoggingEnv())
}