Skip to content

Commit

Permalink
Merge pull request #61 from haya14busa/os-unset-env
Browse files Browse the repository at this point in the history
Use os.Unsetenv() instead of os.Setenv(key, "")
  • Loading branch information
haya14busa committed Dec 15, 2016
2 parents 79d5549 + 6405b45 commit 162ac04
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 8 deletions.
10 changes: 5 additions & 5 deletions cmd/reviewdog/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -144,7 +144,7 @@ func TestRun_travis(t *testing.T) {
saveEnvs := make(map[string]string)
for _, key := range envs {
saveEnvs[key] = os.Getenv(key)
os.Setenv(key, "")
os.Unsetenv(key)
}
// restore
defer func() {
Expand Down Expand Up @@ -236,7 +236,7 @@ func TestCircleci(t *testing.T) {
saveEnvs := make(map[string]string)
for _, key := range envs {
saveEnvs[key] = os.Getenv(key)
os.Setenv(key, "")
os.Unsetenv(key)
}
// restore
defer func() {
Expand All @@ -256,7 +256,7 @@ func TestCircleci(t *testing.T) {
t.Log(err)
}

os.Setenv("CI_PULL_REQUEST", "")
os.Unsetenv("CI_PULL_REQUEST")
os.Setenv("CIRCLE_PR_NUMBER", "invalid")
if _, _, err := circleci(); err == nil {
t.Error("error expected but got nil")
Expand Down Expand Up @@ -322,7 +322,7 @@ func TestDroneio(t *testing.T) {
saveEnvs := make(map[string]string)
for _, key := range envs {
saveEnvs[key] = os.Getenv(key)
os.Setenv(key, "")
os.Unsetenv(key)
}
// restore
defer func() {
Expand Down Expand Up @@ -401,7 +401,7 @@ func TestCommonci(t *testing.T) {
saveEnvs := make(map[string]string)
for _, key := range envs {
saveEnvs[key] = os.Getenv(key)
os.Setenv(key, "")
os.Unsetenv(key)
}
// restore
defer func() {
Expand Down
2 changes: 1 addition & 1 deletion project/run.go
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ var secretEnvs = [...]string{
func filteredEnviron() []string {
for _, name := range secretEnvs {
defer os.Setenv(name, os.Getenv(name))
os.Setenv(name, "")
os.Unsetenv(name)
}
return os.Environ()
}
4 changes: 2 additions & 2 deletions project/run_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -132,8 +132,8 @@ func TestFilteredEnviron(t *testing.T) {
os.Setenv(name, "value")

filtered := filteredEnviron()
if len(filtered) != len(os.Environ()) {
t.Errorf("len(filtered) != len(os.Environ()), %v != %v", len(filtered), len(os.Environ()))
if len(filtered) != len(os.Environ())-1 {
t.Errorf("len(filtered) != len(os.Environ())-1, %v != %v-1", len(filtered), len(os.Environ()))
}

for _, kv := range filtered {
Expand Down

0 comments on commit 162ac04

Please sign in to comment.