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:
@@ -14,8 +14,7 @@ import (
|
||||
func TestExpandVar_EnvSuccessful(t *testing.T) {
|
||||
const key = "GF_TEST_SETTING_EXPANDER_ENV"
|
||||
const expected = "aurora borealis"
|
||||
err := os.Setenv(key, expected)
|
||||
require.NoError(t, err)
|
||||
t.Setenv(key, expected)
|
||||
|
||||
// expanded format
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user