func (s *SnapSuite) TestSnapRunHookMissingHookIntegration(c *check.C) { // mock installed snap dirs.SetRootDir(c.MkDir()) defer func() { dirs.SetRootDir("/") }() // Only create revision 42 snaptest.MockSnap(c, string(mockYaml), &snap.SideInfo{ Revision: snap.R(42), }) // and mock the server s.mockServer(c) // redirect exec called := false restorer := snaprun.MockSyscallExec(func(arg0 string, args []string, envv []string) error { called = true return nil }) defer restorer() err := snaprun.SnapRunHook("snapname", "unset", "missing-hook") c.Assert(err, check.IsNil) c.Check(called, check.Equals, false) }
func (s *SnapSuite) TestSnapRunHookMissingHookIntegration(c *check.C) { // mock installed snap dirs.SetRootDir(c.MkDir()) defer func() { dirs.SetRootDir("/") }() // Only create revision 42 si := snaptest.MockSnap(c, string(mockYaml), &snap.SideInfo{ Revision: snap.R(42), }) err := os.Symlink(si.MountDir(), filepath.Join(si.MountDir(), "../current")) c.Assert(err, check.IsNil) // redirect exec called := false restorer := snaprun.MockSyscallExec(func(arg0 string, args []string, envv []string) error { called = true return nil }) defer restorer() err = snaprun.SnapRunHook("snapname", "unset", "missing-hook") c.Assert(err, check.ErrorMatches, `cannot find hook "missing-hook" in "snapname"`) c.Check(called, check.Equals, false) }