Skip to content

Commit e004c78

Browse files
Win unit test (#355)
* Fixed unit tests so they work in windows environments * Removed dead imports
1 parent 6394821 commit e004c78

File tree

2 files changed

+5
-13
lines changed

2 files changed

+5
-13
lines changed

bluemix/configuration/config_helpers/helpers_test.go

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -10,16 +10,6 @@ import (
1010
"github.com/stretchr/testify/assert"
1111
)
1212

13-
// import (
14-
// "io/ioutil"
15-
// "os"
16-
// "path/filepath"
17-
// "testing"
18-
19-
// "github.com/stretchr/testify/assert"
20-
// "github.ibm.com/bluemix-cli-release/build/src/github.ibm.com/Bluemix/bluemix-cli-common/file_helpers"
21-
// )
22-
2313
func captureAndPrepareEnv(a *assert.Assertions) ([]string, string) {
2414
env := os.Environ()
2515

@@ -30,7 +20,11 @@ func captureAndPrepareEnv(a *assert.Assertions) ([]string, string) {
3020
os.Unsetenv("IBMCLOUD_HOME")
3121
os.Unsetenv("BLUEMIX_HOME")
3222
os.Setenv("HOME", userHome)
33-
23+
// UserHomeDir() uses HOMEDRIVE + HOMEPATH for windows
24+
if os.Getenv("OS") == "Windows_NT" {
25+
// ioutil.TempDir has the drive letter in the path, so we need to remove it when we set HOMEDRIVE
26+
os.Setenv("HOMEPATH", strings.Replace(userHome, os.Getenv("HOMEDRIVE"), "", -1))
27+
}
3428
a.NoError(os.RemoveAll(userHome))
3529

3630
return env, userHome

bluemix/env_test.go

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,6 @@ import (
99
)
1010

1111
func TestGet(t *testing.T) {
12-
assert.Empty(t, EnvTrace.Get())
13-
1412
os.Setenv("IBMCLOUD_TRACE", "true")
1513
assert.Equal(t, "true", EnvTrace.Get())
1614

0 commit comments

Comments
 (0)