示例#1
0
func (s *GetConfigSuite) TestInit(c *gc.C) {
	// zero or one args is fine.
	err := testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), nil)
	c.Check(err, jc.ErrorIsNil)
	err = testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), []string{"one"})
	c.Check(err, jc.ErrorIsNil)
	// More than one is not allowed.
	err = testing.InitCommand(controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store), []string{"one", "two"})
	c.Check(err, gc.ErrorMatches, `unrecognized args: \["two"\]`)
}
示例#2
0
func (s *GetConfigSuite) TestError(c *gc.C) {
	command := controller.NewGetConfigCommandForTest(&fakeControllerAPI{err: errors.New("error")}, s.store)
	_, err := testing.RunCommand(c, command)
	c.Assert(err, gc.ErrorMatches, "error")
}
示例#3
0
func (s *GetConfigSuite) run(c *gc.C, args ...string) (*cmd.Context, error) {
	command := controller.NewGetConfigCommandForTest(&fakeControllerAPI{}, s.store)
	return testing.RunCommand(c, command, args...)
}