mirror of
https://github.com/go-sylixos/elvish.git
synced 2024-12-14 11:17:52 +08:00
21 lines
371 B
Go
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")
|
|
}
|
|
}
|