github.com/rohankumardubey/syslog-redirector-golang@v0.0.0-20140320174030-4859f03d829a/src/pkg/syscall/syscall_test.go (about) 1 // Copyright 2013 The Go Authors. All rights reserved. 2 // Use of this source code is governed by a BSD-style 3 // license that can be found in the LICENSE file. 4 5 package syscall_test 6 7 import ( 8 "syscall" 9 "testing" 10 ) 11 12 func testSetGetenv(t *testing.T, key, value string) { 13 err := syscall.Setenv(key, value) 14 if err != nil { 15 t.Fatalf("Setenv failed to set %q: %v", value, err) 16 } 17 newvalue, found := syscall.Getenv(key) 18 if !found { 19 t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value) 20 } 21 if newvalue != value { 22 t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value) 23 } 24 } 25 26 func TestEnv(t *testing.T) { 27 testSetGetenv(t, "TESTENV", "AVALUE") 28 // make sure TESTENV gets set to "", not deleted 29 testSetGetenv(t, "TESTENV", "") 30 }