Ejemplo n.º 1
0
func (s *enableCommandSuite) TestRun(c *gc.C) {
	for _, test := range []struct {
		args  []string
		type_ string
	}{{
		args:  []string{"all"},
		type_: "BlockChange",
	}, {
		args:  []string{"destroy-model"},
		type_: "BlockDestroy",
	}, {
		args:  []string{"remove-object"},
		type_: "BlockRemove",
	}} {
		mockClient := &mockUnblockClient{}
		cmd := block.NewEnableCommandForTest(mockClient, nil)
		_, err := testing.RunCommand(c, cmd, test.args...)
		c.Check(err, jc.ErrorIsNil)
		c.Check(mockClient.blockType, gc.Equals, test.type_)
	}
}
Ejemplo n.º 2
0
func (s *enableCommandSuite) TestRunError(c *gc.C) {
	mockClient := &mockUnblockClient{err: errors.New("boom")}
	cmd := block.NewEnableCommandForTest(mockClient, nil)
	_, err := testing.RunCommand(c, cmd, "all")
	c.Check(err, gc.ErrorMatches, "boom")
}
Ejemplo n.º 3
0
func (s *enableCommandSuite) TestRunGetAPIError(c *gc.C) {
	cmd := block.NewEnableCommandForTest(nil, errors.New("boom"))
	_, err := testing.RunCommand(c, cmd, "all")
	c.Assert(err.Error(), gc.Equals, "cannot connect to the API: boom")
}