cmd: pretend we're running on Ubuntu in TestExecInCoreSnapUnsetsDidRe… #4235

Merged
merged 3 commits into from Nov 20, 2017

Conversation

Projects
None yet
4 participants
Contributor

bboozzoo commented Nov 16, 2017

…exec()

Mock distribution os-release so that the test runs in a fixed environment.

cmd: pretend we're running on Ubuntu in TestExecInCoreSnapUnsetsDidRe…
…exec()

Mock distribution os-release so that the test runs in a fixed environment.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

@bboozzoo bboozzoo requested a review from mvo5 Nov 16, 2017

+1 but one question

cmd/cmd_test.go
+ restore := release.MockReleaseInfo(&release.OS{ID: "ubuntu"})
+ defer func() {
+ restore()
+ dirs.SetRootDir(s.fakeroot)
@zyga

zyga Nov 16, 2017

Contributor

Did you mean dirs.SetRootDir("/")?

@bboozzoo

bboozzoo Nov 16, 2017

Contributor

No, I actually meant to restore it to whatever was set up by the test suite right here: https://github.com/snapcore/snapd/blob/master/cmd/cmd_test.go#L62

Mocking release info slightly alters how the directories are set up, once it's restored SetRootDir() should also restore the directory paths to their original values.

@zyga

zyga Nov 16, 2017

Contributor

+1

codecov-io commented Nov 16, 2017

Codecov Report

Merging #4235 into master will increase coverage by 0.09%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #4235      +/-   ##
==========================================
+ Coverage   75.87%   75.96%   +0.09%     
==========================================
  Files         440      440              
  Lines       38295    38439     +144     
==========================================
+ Hits        29055    29202     +147     
+ Misses       7224     7223       -1     
+ Partials     2016     2014       -2
Impacted Files Coverage Δ
cmd/snap-update-ns/utils.go 100% <0%> (ø) ⬆️
interfaces/builtin/snapd_control.go 100% <0%> (ø) ⬆️
store/store.go 80.14% <0%> (+0.12%) ⬆️
snap/validate.go 97.08% <0%> (+0.18%) ⬆️
overlord/ifacestate/helpers.go 60.26% <0%> (+0.66%) ⬆️
interfaces/builtin/browser_support.go 80% <0%> (+3.68%) ⬆️
interfaces/builtin/all.go 86.11% <0%> (+12.77%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update e3188c0...7a83466. Read the comment docs.

bboozzoo added some commits Nov 17, 2017

cmd: symlink SnapMountDir to fake snapd directory to hit the ride cod…
…e paths

This ensures we hit the right code paths in TestExecInCoreSnapUnsetsDidReexec()
regardless of the default paths of the host OS.

Signed-off-by: Maciej Borzecki <maciej.zenon.borzecki@canonical.com>

mvo5 approved these changes Nov 17, 2017

Collaborator

mvo5 commented Nov 17, 2017

Thanks for chasing this!

Contributor

bboozzoo commented Nov 17, 2017

Travis hit a timeout, restarted the build.

@mvo5 mvo5 merged commit 0c48fc8 into snapcore:master Nov 20, 2017

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed
Details
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment