elvish/pkg/util/temp_env_test.go
2019-12-23 20:00:59 +00:00

21 lines
371 B
Go

package util
import (
"os"
"testing"
)
func TestWithTempEnv(t *testing.T) {
envName := "ELVISH_TEST_ENV"
os.Setenv(envName, "old value")
restore := WithTempEnv(envName, "new value")
if os.Getenv(envName) != "new value" {
t.Errorf("did not set to new value")
}
restore()
if os.Getenv(envName) != "old value" {
t.Errorf("did not restore to old value")
}
}