func (s *ExecSuite) TestBadHook(c *C) { charmDir, outPath := makeCharm(c, "occurrence-occurred", 0700, 99) info := getInfo(charmDir, "") err := hook.Exec("occurrence-occurred", info) c.Assert(err, ErrorMatches, "exit status 99") s.AssertEnv(c, outPath, map[string]string{"CHARM_DIR": charmDir}) }
func (s *ExecSuite) TestGoodHook(c *C) { charmDir, outPath := makeCharm(c, "something-happened", 0700, 0) info := getInfo(charmDir, "remote/123") err := hook.Exec("something-happened", info) c.Assert(err, IsNil) s.AssertEnv(c, outPath, map[string]string{ "CHARM_DIR": charmDir, "JUJU_REMOTE_UNIT": "remote/123", }) }
func (s *ExecSuite) TestNonExecutableHook(c *C) { charmDir, _ := makeCharm(c, "something-happened", 0600, 0) info := getInfo(charmDir, "") err := hook.Exec("something-happened", info) c.Assert(err, ErrorMatches, `exec: ".*/something-happened": permission denied`) }
func (s *ExecSuite) TestNoHook(c *C) { info := getInfo(c.MkDir(), "") err := hook.Exec("tree-fell-in-forest", info) c.Assert(err, IsNil) }