Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code | Sign in
(678)

Delta Between Two Patch Sets: src/os/env_test.go

Issue 148370043: code review 148370043: os, syscall: add Unsetenv (Closed)
Left Patch Set: diff -r 61525d46311930992512297749c1ad914912041b https://go.googlecode.com/hg/ Created 10 years, 5 months ago
Right Patch Set: diff -r 3042795874453efa7be0a082f3f85118b9d06432 https://go.googlecode.com/hg/ Created 10 years, 5 months ago
Left:
Right:
Use n/p to move between diff chunks; N/P to move between comments. Please Sign in to add in-line comments.
Jump to:
Left: Side by side diff | Download
Right: Side by side diff | Download
« no previous file with change/comment | « src/os/env.go ('k') | src/runtime/cgo/gcc_setenv.c » ('j') | no next file with change/comment »
Toggle Intra-line Diffs ('i') | Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
LEFTRIGHT
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
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 }
LEFTRIGHT

Powered by Google App Engine
RSS Feeds Recent Issues | This issue
This is Rietveld f62528b