// 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") } }