func (s *mountunitSuite) TestAddMountUnit(c *C) { info := &snap.Info{ SideInfo: snap.SideInfo{ RealName: "foo", Revision: snap.R(13), }, Version: "1.1", Architectures: []string{"all"}, } err := backend.AddMountUnit(info, &s.nullProgress) c.Assert(err, IsNil) // ensure correct mount unit mount, err := ioutil.ReadFile(filepath.Join(dirs.SnapServicesDir, "snap-foo-13.mount")) c.Assert(err, IsNil) c.Assert(string(mount), Equals, `[Unit] Description=Mount unit for foo [Mount] What=/var/lib/snapd/snaps/foo_13.snap Where=/snap/foo/13 Type=squashfs [Install] WantedBy=multi-user.target `) }
func (s *mountunitSuite) TestRemoveMountUnit(c *C) { info := &snap.Info{ SideInfo: snap.SideInfo{ RealName: "foo", Revision: snap.R(13), }, Version: "1.1", Architectures: []string{"all"}, } err := backend.AddMountUnit(info, &s.nullProgress) c.Assert(err, IsNil) // ensure we have the files p := filepath.Join(dirs.SnapServicesDir, "snap-foo-13.mount") c.Assert(osutil.FileExists(p), Equals, true) // now call remove and ensure they are gone err = backend.RemoveMountUnit(info.MountDir(), &s.nullProgress) c.Assert(err, IsNil) p = filepath.Join(dirs.SnapServicesDir, "snaps-foo-13.mount") c.Assert(osutil.FileExists(p), Equals, false) }