예제 #1
0
func (s *isLeaderSuite) TestFormatError(c *gc.C) {
	command := jujuc.NewIsLeaderCommand(nil)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, []string{"--format", "bad"})
	c.Check(code, gc.Equals, 2)
	c.Check(bufferString(runContext.Stdout), gc.Equals, "")
	c.Check(bufferString(runContext.Stderr), gc.Equals, `error: invalid value "bad" for flag --format: unknown format "bad"`+"\n")
}
예제 #2
0
func (s *isLeaderSuite) testParseOutput(c *gc.C, leader bool, args []string, checker gc.Checker) {
	jujucContext := &isLeaderContext{leader: leader}
	command := jujuc.NewIsLeaderCommand(jujucContext)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, args)
	c.Check(code, gc.Equals, 0)
	c.Check(jujucContext.called, jc.IsTrue)
	c.Check(bufferString(runContext.Stdout), checker, leader)
	c.Check(bufferString(runContext.Stderr), gc.Equals, "")
}
예제 #3
0
func (s *isLeaderSuite) TestIsLeaderError(c *gc.C) {
	jujucContext := &isLeaderContext{err: errors.New("pow")}
	command := jujuc.NewIsLeaderCommand(jujucContext)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, nil)
	c.Check(code, gc.Equals, 1)
	c.Check(jujucContext.called, jc.IsTrue)
	c.Check(bufferString(runContext.Stdout), gc.Equals, "")
	c.Check(bufferString(runContext.Stderr), gc.Equals, "error: leadership status unknown: pow\n")
}
예제 #4
0
파일: is-leader_test.go 프로젝트: bac/juju
func (s *isLeaderSuite) testOutput(c *gc.C, leader bool, args []string, expect string) {
	jujucContext := &isLeaderContext{leader: leader}
	command, err := jujuc.NewIsLeaderCommand(jujucContext)
	c.Assert(err, jc.ErrorIsNil)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, args)
	c.Check(code, gc.Equals, 0)
	c.Check(jujucContext.called, jc.IsTrue)
	c.Check(bufferString(runContext.Stdout), gc.Equals, expect)
	c.Check(bufferString(runContext.Stderr), gc.Equals, "")
}
예제 #5
0
func (s *isLeaderSuite) TestInitSuccess(c *gc.C) {
	command := jujuc.NewIsLeaderCommand(nil)
	err := command.Init(nil)
	c.Assert(err, jc.ErrorIsNil)
}
예제 #6
0
func (s *isLeaderSuite) TestInitError(c *gc.C) {
	command := jujuc.NewIsLeaderCommand(nil)
	err := command.Init([]string{"blah"})
	c.Assert(err, gc.ErrorMatches, `unrecognized args: \["blah"\]`)
}