예제 #1
0
func (s *leaderGetSuite) TestFormatError(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(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 *leaderGetSuite) TestSettingsError(c *gc.C) {
	jujucContext := newLeaderGetContext(errors.New("zap"))
	command := jujuc.NewLeaderGetCommand(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: cannot read leadership settings: zap\n")
}
예제 #3
0
func (s *leaderGetSuite) testParseOutput(c *gc.C, args []string, checker gc.Checker, expect interface{}) {
	jujucContext := newLeaderGetContext(nil)
	command := jujuc.NewLeaderGetCommand(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, expect)
	c.Check(bufferString(runContext.Stderr), gc.Equals, "")
}
예제 #4
0
파일: leader-get_test.go 프로젝트: bac/juju
func (s *leaderGetSuite) SetUpTest(c *gc.C) {
	s.BaseSuite.SetUpTest(c)
	var err error
	s.command, err = jujuc.NewLeaderGetCommand(nil)
	c.Assert(err, jc.ErrorIsNil)
}
예제 #5
0
func (s *leaderGetSuite) TestInitEmpty(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(nil)
	err := command.Init(nil)
	c.Assert(err, jc.ErrorIsNil)
}
예제 #6
0
func (s *leaderGetSuite) TestInitAll(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(nil)
	err := command.Init([]string{"-"})
	c.Assert(err, jc.ErrorIsNil)
}
예제 #7
0
func (s *leaderGetSuite) TestInitError(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(nil)
	err := command.Init([]string{"x=x"})
	c.Assert(err, gc.ErrorMatches, `invalid key "x=x"`)
}