Replace os.Setenv with t.Setenv (#6345)

This commit is contained in:
Sam Coe 2022-09-26 13:37:34 +04:00 committed by GitHub
parent 471cbea4fa
commit ebc681be05
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -72,9 +72,7 @@ func NewFromString(cfgStr string) *ConfigMock {
func StubWriteConfig(t *testing.T) func(io.Writer, io.Writer) {
t.Helper()
tempDir := t.TempDir()
old := os.Getenv("GH_CONFIG_DIR")
os.Setenv("GH_CONFIG_DIR", tempDir)
t.Cleanup(func() { os.Setenv("GH_CONFIG_DIR", old) })
t.Setenv("GH_CONFIG_DIR", tempDir)
return func(wc io.Writer, wh io.Writer) {
config, err := os.Open(filepath.Join(tempDir, "config.yml"))
if err != nil {