Skip to content

Commit

Permalink
Fixes for the test to run on windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Israel Fruchter (ifruchte) committed May 6, 2018
1 parent f09b206 commit 98b1926
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 4 deletions.
15 changes: 12 additions & 3 deletions client/client_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -210,7 +210,11 @@ func TestUpdateFeatures(t *testing.T) {
}`)

cfg := config.DefaultConfig()
cfg.Git.RepoPath = "/tmp"
dir, err := ioutil.TempDir("", "example")
if err != nil {
log.Fatal(err)
}
cfg.Git.RepoPath = dir
c, _ := New(cfg)
c.UpdateFeatures(raw)

Expand All @@ -235,14 +239,19 @@ func TestClient_UpdateFeatures_Failure(t *testing.T) {
},`)

cfg := config.DefaultConfig()
cfg.Git.RepoPath = "/tmp"
dir, err := ioutil.TempDir("", "example")
if err != nil {
log.Fatal(err)
}
cfg.Git.RepoPath = dir
c, _ := New(cfg)
c.UpdateFeatures(badUpdate)
assert.EqualValues(t, models.EmptyFeatureMap(), c.FeatureMap(), "Assert bad payload returns empty feature map")
}

func TestWatch(t *testing.T) {
p := "/tmp/decider.json"
tmpfile, err := ioutil.TempFile("", "example")
p := tmpfile.Name()
fm, err := models.NewFeatureMap(JSONBytes)
assert.NoError(t, err)
err = ioutil.WriteFile(p, JSONBytes, 0644)
Expand Down
9 changes: 8 additions & 1 deletion config/config_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import (
"os/user"
"testing"

"io/ioutil"

"os"

"fmt"
Expand Down Expand Up @@ -41,7 +43,12 @@ func TestDefaultConfig(t *testing.T) {
}

func TestEnvOverride(t *testing.T) {
os.Setenv(envConfigDirOverride, "/tmp/dcdr")
dir, err := ioutil.TempDir("", "example")
assert.NoError(t, err)

defer os.RemoveAll(dir)

os.Setenv(envConfigDirOverride, dir)
cfg := LoadConfig()

assert.Equal(t, Path(), fmt.Sprintf("%s/%s", os.Getenv(envConfigDirOverride), configFileName))
Expand Down

0 comments on commit 98b1926

Please sign in to comment.