github.com/Kalvelign/golang-windows-sys-lib@v0.0.0-20221121121202-63da651435e1/plan9/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  //go:build plan9
     6  // +build plan9
     7  
     8  package plan9_test
     9  
    10  import (
    11  	"testing"
    12  
    13  	"golang.org/x/sys/plan9"
    14  )
    15  
    16  func testSetGetenv(t *testing.T, key, value string) {
    17  	err := plan9.Setenv(key, value)
    18  	if err != nil {
    19  		t.Fatalf("Setenv failed to set %q: %v", value, err)
    20  	}
    21  	newvalue, found := plan9.Getenv(key)
    22  	if !found {
    23  		t.Fatalf("Getenv failed to find %v variable (want value %q)", key, value)
    24  	}
    25  	if newvalue != value {
    26  		t.Fatalf("Getenv(%v) = %q; want %q", key, newvalue, value)
    27  	}
    28  }
    29  
    30  func TestEnv(t *testing.T) {
    31  	testSetGetenv(t, "TESTENV", "AVALUE")
    32  	// make sure TESTENV gets set to "", not deleted
    33  	testSetGetenv(t, "TESTENV", "")
    34  }