Beispiel #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")
}
Beispiel #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")
}
Beispiel #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, "")
}
Beispiel #4
0
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)
}
Beispiel #5
0
func (s *leaderGetSuite) TestInitEmpty(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(nil)
	err := command.Init(nil)
	c.Assert(err, jc.ErrorIsNil)
}
Beispiel #6
0
func (s *leaderGetSuite) TestInitAll(c *gc.C) {
	command := jujuc.NewLeaderGetCommand(nil)
	err := command.Init([]string{"-"})
	c.Assert(err, jc.ErrorIsNil)
}
Beispiel #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"`)
}