예제 #1
0
파일: args_test.go 프로젝트: Pankov404/juju
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"))
}
예제 #2
0
파일: args_test.go 프로젝트: Pankov404/juju
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, "")
}
예제 #3
0
파일: args_test.go 프로젝트: Pankov404/juju
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)
}