Skip to content

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
docker:masterfrom
tsuna:master
Open

cli/config/configfile: Make sure to not leak a temp config behind and improve unit tests#1366
tsuna wants to merge 1 commit into
docker:masterfrom
tsuna:master

Conversation

@tsuna
Copy link
Copy Markdown
Contributor

@tsuna tsuna commented Sep 12, 2018

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)

🦋

thaJeztah
thaJeztah previously approved these changes Sep 12, 2018
Copy link
Copy Markdown
Member

@thaJeztah thaJeztah left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

Comment thread cli/config/configfile/file.go Outdated
if err != nil {
return err
}
defer os.Remove(temp.Name())
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this would also attempt to remove temp.Name() in the happy case (i.e., it being succesfully renamed); guess that's not a problem.

Copy link
Copy Markdown
Collaborator

@vdemeester vdemeester left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hum, the new test is failing though 😓

@thaJeztah
Copy link
Copy Markdown
Member

oh! hm...

@tsuna
Copy link
Copy Markdown
Contributor Author

tsuna commented Sep 14, 2018

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.

@thaJeztah
Copy link
Copy Markdown
Member

Could it be because the tests run docker-in-docker, and tests are running as root?

Signed-off-by: Benoit Sigoure <tsunanet@gmail.com>
Signed-off-by: Sebastiaan van Stijn <github@gone.nl>
@codecov-commenter
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants