Ejemplo n.º 1
0
func (s *WindowsHookSuite) TestSearchHookWindows(c *gc.C) {
	restorer := envtesting.PatchValue(&version.Current.OS, version.Windows)
	defer restorer()

	charmDir := c.MkDir()
	makeCharm(c, hookSpec{
		dir:  "hooks",
		name: "something-happened.ps1",
		perm: 0755,
	}, charmDir)

	obtained, err := runner.SearchHook(charmDir, filepath.Join("hooks", "something-happened"))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(obtained, gc.Equals, filepath.Join(charmDir, "hooks", "something-happened.ps1"))
}
Ejemplo n.º 2
0
func (s *WindowsHookSuite) TestSearchHookWindowsError(c *gc.C) {
	restorer := envtesting.PatchValue(&version.Current.OS, version.Windows)
	defer restorer()

	charmDir := c.MkDir()
	makeCharm(c, hookSpec{
		dir:  "hooks",
		name: "something-happened.linux",
		perm: 0755,
	}, charmDir)

	obtained, err := runner.SearchHook(charmDir, filepath.Join("hooks", "something-happened"))
	c.Assert(err.Error(), gc.Equals, filepath.FromSlash("hooks/something-happened does not exist"))
	c.Assert(obtained, gc.Equals, "")
}
Ejemplo n.º 3
0
func (s *WindowsHookSuite) TestSearchHookUbuntu(c *gc.C) {
	if runtime.GOOS == "windows" {
		c.Skip("Cannot search for executables without extension on windows")
	}
	restorer := envtesting.PatchValue(&version.Current.OS, version.Ubuntu)
	defer restorer()

	charmDir := c.MkDir()
	makeCharm(c, hookSpec{
		dir:  "hooks",
		name: "something-happened",
		perm: 0755,
	}, charmDir)

	expected, err := runner.LookPath(filepath.Join(charmDir, "hooks", "something-happened"))
	c.Assert(err, jc.ErrorIsNil)
	obtained, err := runner.SearchHook(charmDir, filepath.Join("hooks", "something-happened"))
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(obtained, gc.Equals, expected)
}