Left: | ||
Right: |
LEFT | RIGHT |
---|---|
1 // Copyright 2010 The Go Authors. All rights reserved. | 1 // Copyright 2010 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package os_test | 5 package os_test |
6 | 6 |
7 import ( | 7 import ( |
8 . "os" | 8 . "os" |
9 "reflect" | 9 "reflect" |
10 "strings" | 10 "strings" |
(...skipping 52 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
63 func TestConsistentEnviron(t *testing.T) { | 63 func TestConsistentEnviron(t *testing.T) { |
64 e0 := Environ() | 64 e0 := Environ() |
65 for i := 0; i < 10; i++ { | 65 for i := 0; i < 10; i++ { |
66 e1 := Environ() | 66 e1 := Environ() |
67 if !reflect.DeepEqual(e0, e1) { | 67 if !reflect.DeepEqual(e0, e1) { |
68 t.Fatalf("environment changed") | 68 t.Fatalf("environment changed") |
69 } | 69 } |
70 } | 70 } |
71 } | 71 } |
72 | 72 |
73 func TestUnsetEnv(t *testing.T) { | 73 func TestUnsetenv(t *testing.T) { |
r
2014/10/01 02:13:02
TestUnsetenv
| |
74 » const testKey = "TestUnsetEnv" | 74 » const testKey = "GO_TEST_UNSETENV" |
r
2014/10/01 02:13:03
ditto
| |
75 set := func() bool { | 75 set := func() bool { |
76 prefix := testKey + "=" | |
76 for _, key := range Environ() { | 77 for _, key := range Environ() { |
77 » » » if strings.HasPrefix(key, testKey+"=") { | 78 » » » if strings.HasPrefix(key, prefix) { |
78 return true | 79 return true |
79 } | 80 } |
80 } | 81 } |
81 return false | 82 return false |
82 } | 83 } |
83 » Setenv(testKey, "1") | 84 » if err := Setenv(testKey, "1"); err != nil { |
r
2014/10/01 02:13:03
check error
| |
85 » » t.Fatalf("Setenv: %v", err) | |
86 » } | |
84 if !set() { | 87 if !set() { |
85 » » t.Fatal("Setenv didn't set TestUnsetEnv") | 88 » » t.Error("Setenv didn't set TestUnsetenv") |
86 } | 89 } |
87 » Unsetenv(testKey) | 90 » if err := Unsetenv(testKey); err != nil { |
r
2014/10/01 02:13:03
check error
| |
91 » » t.Fatalf("Unsetenv: %v", err) | |
92 » } | |
88 if set() { | 93 if set() { |
89 » » t.Fatal("Unsetenv didn't clear TestUnsetEnv") | 94 » » t.Fatal("Unsetenv didn't clear TestUnsetenv") |
90 } | 95 } |
91 } | 96 } |
LEFT | RIGHT |