-
Notifications
You must be signed in to change notification settings - Fork 12
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Fixes for the test to run on windows #71
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -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) | ||
|
||
|
@@ -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") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Let's name this It seems like it's up to us to clean up this file as well. |
||
p := tmpfile.Name() | ||
fm, err := models.NewFeatureMap(JSONBytes) | ||
assert.NoError(t, err) | ||
err = ioutil.WriteFile(p, JSONBytes, 0644) | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,6 +4,8 @@ import ( | |
"os/user" | ||
"testing" | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. May we lint these imports? I know this was an error before you change but since you're here. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've fixed the other issues, but I'm not sure what exactly you mean like this imports... care to elabrate ? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Sure, it's a nitpick but the imports, the declarations for dependencies for this file, are not ordered properly:
Unfortunately This is not necessary to merge this PR. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. ordering of imports, got it (i'll try to noticed it next time around) |
||
"io/ioutil" | ||
|
||
"os" | ||
|
||
"fmt" | ||
|
@@ -41,7 +43,12 @@ func TestDefaultConfig(t *testing.T) { | |
} | ||
|
||
func TestEnvOverride(t *testing.T) { | ||
os.Setenv(envConfigDirOverride, "/tmp/dcdr") | ||
dir, err := ioutil.TempDir("", "example") | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same, as above let's use a more relatable name. |
||
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)) | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
May we generalize these into a shared function, something like this:
We can also use
t.Fatalf
to allow the test-suite to handle the error gracefully. Also we should prefix the directory with a related to this project:dcdr
or similar.Then from each test case we can call the parent function and not need to handle the errors: