Files
tinygo/src/os/env_test.go
T
2021-12-13 23:05:17 +01:00

39 lines
868 B
Go

// Copyright 2010 The Go Authors. All rights reserved.
// Use of this source code is governed by a BSD-style
// license that can be found in the LICENSE file.
package os_test
import (
. "os"
"reflect"
"testing"
)
func TestConsistentEnviron(t *testing.T) {
e0 := Environ()
for i := 0; i < 10; i++ {
e1 := Environ()
if !reflect.DeepEqual(e0, e1) {
t.Fatalf("environment changed")
}
}
}
func TestLookupEnv(t *testing.T) {
const smallpox = "SMALLPOX" // No one has smallpox.
value, ok := LookupEnv(smallpox) // Should not exist.
if ok || value != "" {
t.Fatalf("%s=%q", smallpox, value)
}
defer Unsetenv(smallpox)
err := Setenv(smallpox, "virus")
if err != nil {
t.Fatalf("failed to release smallpox virus")
}
_, ok = LookupEnv(smallpox)
if !ok {
t.Errorf("smallpox release failed; world remains safe but LookupEnv is broken")
}
}