cli/config/configfile: Make sure to not leak a temp config behind and improve unit tests#1366
Open
tsuna wants to merge 1 commit into
Open
cli/config/configfile: Make sure to not leak a temp config behind and improve unit tests#1366tsuna wants to merge 1 commit into
tsuna wants to merge 1 commit into
Conversation
thaJeztah
previously approved these changes
Sep 12, 2018
| if err != nil { | ||
| return err | ||
| } | ||
| defer os.Remove(temp.Name()) |
Member
There was a problem hiding this comment.
this would also attempt to remove temp.Name() in the happy case (i.e., it being succesfully renamed); guess that's not a problem.
vdemeester
reviewed
Sep 12, 2018
Collaborator
vdemeester
left a comment
There was a problem hiding this comment.
Hum, the new test is failing though 😓
Member
|
oh! hm... |
Contributor
Author
|
I haven't yet had time to figure out why this is failing on CirleCI, it's as if the test's attempt to make the test directory read-only wasn't actually making it read-only... maybe they do something funky with the filesystem there. 🤔 I'll follow up as soon as I have a few free cycles, sorry guys. |
Member
|
Could it be because the tests run docker-in-docker, and tests are running as |
Signed-off-by: Benoit Sigoure <tsunanet@gmail.com> Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
Codecov Report✅ All modified and coverable lines are covered by tests. 📢 Thoughts on this report? Let us know! |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This is a small followup change to #1359. It addresses the astute observation from @thaJeztah that we can potentially leak temp files in the config directory. While I couldn't easily test this particular failure from the unit test, I took the opportunity to expand the unit test to cover a few failure modes.
cc @vdemeester — thanks guys.
- A picture of a cute animal (not mandatory but encouraged)
🦋