overlord/snapstate: respect SnapMountDir in tests #1745

Closed
wants to merge 2 commits into
from

Conversation

Projects
None yet
3 participants
Contributor

zyga commented Aug 24, 2016

Signed-off-by: Zygmunt Krynicki zygmunt.krynicki@canonical.com

overlord/snapstate: respect SnapMountDir in tests
Signed-off-by: Zygmunt Krynicki <zygmunt.krynicki@canonical.com>
overlord/snapstate/snapmgr_test.go
@@ -641,7 +642,7 @@ func (s *snapmgrTestSuite) TestInstallRunThrough(c *C) {
},
{
op: "copy-data",
- name: "/snap/some-snap/11",
+ name: fmt.Sprintf("%s/some-snap/11", dirs.SnapMountDir),
@niemeyer

niemeyer Aug 24, 2016

Contributor

Is there a real benefit in doing this? Why isn't that path hardcoded for these tests?

@zyga

zyga Aug 24, 2016

Contributor

I want the tests to pass if that path is changed. This way we know that there's nothing hardcoded / hidden and buggy when the path is different.

@niemeyer

niemeyer Aug 24, 2016

Contributor

We don't need to reassure that this path is not hardcoded on every single place we use snap.Info. If you want to make sure the path is right, let's please have one test that checks the path is right in the specific place you are concerned about, rather than duplicating that logic in hundreds of places.

@zyga

zyga Aug 24, 2016

Contributor

Hmm, how would you suggest I do two things:

  • patch SnapMountDir in a distribution
  • run tests successfully

Without completing this patch set? I agree it's a bit annoying (there's just a few more small patches after this one and it's all done).

@Conan-Kudo

Conan-Kudo Aug 30, 2016

Contributor

@niemeyer I would disagree and suggest that having it not hardcoded anywhere and then being able to create mock tests where you try different paths and everything works is important. Snaps are supposed to not care about where they exist on the host filesystem, and this is a good way to prove it.

Contributor

Conan-Kudo commented Aug 26, 2016

👍

Contributor

niemeyer commented Aug 26, 2016

Per comment above, we don't want to sprinkle around Sprintfs on every use of snap.Info I think.

I'd suggest dirs.MockSnapMountDir("/snap"), similar to how we have MockOnClassic and MockReleaseInfo. See:

https://github.com/snapcore/snapd/tree/master/release/release.go#L146

(comment repeated here so it doesn't get buried)

@niemeyer niemeyer added the Reviewed label Aug 26, 2016

Contributor

zyga commented Aug 30, 2016

I'll add mocking and reopen. Thanks :-)

@niemeyer niemeyer closed this Aug 30, 2016

@zyga zyga deleted the zyga:salvage branch Dec 12, 2016

@zyga zyga restored the zyga:salvage branch Dec 12, 2016

@zyga zyga deleted the zyga:salvage branch Aug 22, 2017

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