Ejemplo n.º 1
0
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})
}
Ejemplo n.º 2
0
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",
	})
}
Ejemplo n.º 3
0
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`)
}
Ejemplo n.º 4
0
func (s *ExecSuite) TestNoHook(c *C) {
	info := getInfo(c.MkDir(), "")
	err := hook.Exec("tree-fell-in-forest", info)
	c.Assert(err, IsNil)
}