Beispiel #1
0
func (s *leaderSetSuite) TestWriteError(c *gc.C) {
	jujucContext := &leaderSetContext{err: errors.New("splat")}
	command := jujuc.NewLeaderSetCommand(jujucContext)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, []string{"foo=bar"})
	c.Check(code, gc.Equals, 1)
	c.Check(jujucContext.gotSettings, jc.DeepEquals, map[string]string{"foo": "bar"})
	c.Check(bufferString(runContext.Stdout), gc.Equals, "")
	c.Check(bufferString(runContext.Stderr), gc.Equals, "error: cannot write leadership settings: splat\n")
}
Beispiel #2
0
func (s *leaderSetSuite) TestWriteEmpty(c *gc.C) {
	jujucContext := &leaderSetContext{}
	command := jujuc.NewLeaderSetCommand(jujucContext)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, nil)
	c.Check(code, gc.Equals, 0)
	c.Check(jujucContext.gotSettings, jc.DeepEquals, map[string]string{})
	c.Check(bufferString(runContext.Stdout), gc.Equals, "")
	c.Check(bufferString(runContext.Stderr), gc.Equals, "")
}
Beispiel #3
0
func (s *leaderSetSuite) TestWriteValues(c *gc.C) {
	jujucContext := &leaderSetContext{}
	command := jujuc.NewLeaderSetCommand(jujucContext)
	runContext := testing.Context(c)
	code := cmd.Main(command, runContext, []string{"foo=bar", "baz=qux"})
	c.Check(code, gc.Equals, 0)
	c.Check(jujucContext.gotSettings, jc.DeepEquals, map[string]string{
		"foo": "bar",
		"baz": "qux",
	})
	c.Check(bufferString(runContext.Stdout), gc.Equals, "")
	c.Check(bufferString(runContext.Stderr), gc.Equals, "")
}
Beispiel #4
0
func (s *leaderSetSuite) SetUpTest(c *gc.C) {
	var err error
	s.command, err = jujuc.NewLeaderSetCommand(nil)
	c.Assert(err, jc.ErrorIsNil)
}
Beispiel #5
0
func (s *leaderSetSuite) TestInitError(c *gc.C) {
	command := jujuc.NewLeaderSetCommand(nil)
	err := command.Init([]string{"nonsense"})
	c.Check(err, gc.ErrorMatches, `expected "key=value", got "nonsense"`)
}
Beispiel #6
0
func (s *leaderSetSuite) TestInitValues(c *gc.C) {
	command := jujuc.NewLeaderSetCommand(nil)
	err := command.Init([]string{"foo=bar", "baz=qux"})
	c.Check(err, jc.ErrorIsNil)
}
Beispiel #7
0
func (s *leaderSetSuite) TestInitEmpty(c *gc.C) {
	command := jujuc.NewLeaderSetCommand(nil)
	err := command.Init(nil)
	c.Check(err, jc.ErrorIsNil)
}