-
Notifications
You must be signed in to change notification settings - Fork 1.9k
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
cli/config: prevent warning if HOME is not set #2934
Changes from all commits
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 |
---|---|---|
|
@@ -115,6 +115,7 @@ password`: "Invalid Auth config file", | |
email`: "Invalid auth configuration file", | ||
} | ||
|
||
resetHomeDir() | ||
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'm a bit on the fence between calling this function for each test as first step, to make sure the path is clean for the test, OR defer it at first step, to make sure everything will be cleared for other tests. 🤔 func TestOldInvalidsAuth(t *testing.T) {
defer resetHomeDir()
...
} func TestOldInvalidsAuth(t *testing.T) {
resetHomeDir()
...
} 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. It's tricky; any test that uses the |
||
tmpHome, err := ioutil.TempDir("", "config-test") | ||
assert.NilError(t, err) | ||
defer os.RemoveAll(tmpHome) | ||
|
@@ -131,6 +132,7 @@ email`: "Invalid auth configuration file", | |
} | ||
|
||
func TestOldValidAuth(t *testing.T) { | ||
resetHomeDir() | ||
tmpHome, err := ioutil.TempDir("", "config-test") | ||
assert.NilError(t, err) | ||
defer os.RemoveAll(tmpHome) | ||
|
@@ -165,6 +167,7 @@ func TestOldValidAuth(t *testing.T) { | |
} | ||
|
||
func TestOldJSONInvalid(t *testing.T) { | ||
resetHomeDir() | ||
tmpHome, err := ioutil.TempDir("", "config-test") | ||
assert.NilError(t, err) | ||
defer os.RemoveAll(tmpHome) | ||
|
@@ -184,6 +187,7 @@ func TestOldJSONInvalid(t *testing.T) { | |
} | ||
|
||
func TestOldJSON(t *testing.T) { | ||
resetHomeDir() | ||
tmpHome, err := ioutil.TempDir("", "config-test") | ||
assert.NilError(t, err) | ||
defer os.RemoveAll(tmpHome) | ||
|
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.
Maybe we can move this function in the tests files? I mean, tests are in the same package, so they have access to the
homeDir
variable.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.
Yes, I was on the fence what would be better; I put it in the non-test file to make it more visible (I really don't like having to do this 😞)