mirror of
https://github.com/grafana/grafana.git
synced 2025-08-02 12:02:18 +08:00
Tests: use t.Setenv
to set env vars (#69516)
This commit replaces `os.Setenv` with `t.Setenv` in tests. The environment variable is automatically restored to its original value when the test and all its subtests complete. Reference: https://pkg.go.dev/testing#T.Setenv Signed-off-by: Eng Zer Jun <engzerjun@gmail.com>
This commit is contained in:
5
pkg/build/env/fallback_test.go
vendored
5
pkg/build/env/fallback_test.go
vendored
@ -135,9 +135,6 @@ func setEnv(t *testing.T, key, value string) string {
|
||||
t.Helper()
|
||||
os.Clearenv()
|
||||
|
||||
err := os.Setenv(key, value)
|
||||
if err != nil {
|
||||
require.NoError(t, err)
|
||||
}
|
||||
t.Setenv(key, value)
|
||||
return key
|
||||
}
|
||||
|
Reference in New Issue
Block a user