...
1
2
3
4
5
6
7 package plan9_test
8
9 import (
10 "testing"
11
12 "golang.org/x/sys/plan9"
13 )
14
15 func testSetGetenv(t *testing.T, key, value string) {
16 err := plan9.Setenv(key, value)
17 if err != nil {
18 t.Fatalf("Setenv failed to set %q: %v", value, err)
19 }
20 newvalue, found := plan9.Getenv(key)
21 if !found {
22 t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
23 }
24 if newvalue != value {
25 t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
26 }
27 }
28
29 func TestEnv(t *testing.T) {
30 testSetGetenv(t, "TESTENV", "AVALUE")
31
32 testSetGetenv(t, "TESTENV", "")
33 }
34
View as plain text