Esempio n. 1
0
func (s *WindowsHookSuite) TestSearchHookWindowsError(c *gc.C) {
	charmDir, _ := makeCharm(c, hookSpec{
		name: "something-happened.linux",
		perm: 0755,
	})

	restorer := envtesting.PatchValue(&version.Current.OS, version.Windows)
	defer restorer()
	obtained, err := uniter.SearchHook(charmDir, filepath.Join("hooks", "something-happened"))
	c.Assert(err, gc.ErrorMatches, "hooks/something-happened does not exist")
	c.Assert(obtained, gc.Equals, "")
}
Esempio n. 2
0
func (s *WindowsHookSuite) TestSearchHookWindows(c *gc.C) {
	charmDir, _ := makeCharm(c, hookSpec{
		name: "something-happened.ps1",
		perm: 0755,
	})

	restorer := envtesting.PatchValue(&version.Current.OS, version.Windows)

	defer restorer()
	obtained, err := uniter.SearchHook(charmDir, filepath.Join("hooks", "something-happened"))
	c.Assert(err, gc.IsNil)
	c.Assert(obtained, gc.Equals, filepath.Join(charmDir, "hooks", "something-happened.ps1"))
}
Esempio n. 3
0
func (s *WindowsHookSuite) TestSearchHookUbuntu(c *gc.C) {
	if runtime.GOOS == "windows" {
		c.Skip("Skipping hook with no extension on Windows")
	}
	charmDir, _ := makeCharm(c, hookSpec{
		name: "something-happened",
		perm: 0755,
	})

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