Exemplo n.º 1
0
func (s *setBudgetSuite) TestSetBudgetErrors(c *gc.C) {
	tests := []struct {
		about         string
		args          []string
		expectedError string
	}{
		{
			about:         "value needs to be a number",
			args:          []string{"name", "badvalue"},
			expectedError: "budget value needs to be a whole number",
		},
		{
			about:         "value is missing",
			args:          []string{"name"},
			expectedError: "name and value required",
		},
		{
			about:         "no args",
			args:          []string{},
			expectedError: "name and value required",
		},
	}
	for i, test := range tests {
		c.Logf("test %d: %s", i, test.about)
		s.stub.SetErrors(errors.New(test.expectedError))
		defer s.mockAPI.ResetCalls()
		set := setbudget.NewSetBudgetCommand()
		_, err := cmdtesting.RunCommand(c, set, test.args...)
		c.Assert(err, gc.ErrorMatches, test.expectedError)
		s.mockAPI.CheckNoCalls(c)
	}
}
Exemplo n.º 2
0
func (s *setBudgetSuite) TestSetBudgetAPIError(c *gc.C) {
	s.stub.SetErrors(errors.New("something failed"))
	set := setbudget.NewSetBudgetCommand()
	_, err := cmdtesting.RunCommand(c, set, "name", "5")
	c.Assert(err, gc.ErrorMatches, "failed to set the budget: something failed")
	s.mockAPI.CheckCall(c, 0, "SetBudget", "name", "5")
}
Exemplo n.º 3
0
func (s *setBudgetSuite) TestSetBudget(c *gc.C) {
	s.mockAPI.resp = "name budget set to 5"
	set := setbudget.NewSetBudgetCommand()
	ctx, err := cmdtesting.RunCommand(c, set, "name", "5")
	c.Assert(err, jc.ErrorIsNil)
	c.Assert(cmdtesting.Stdout(ctx), jc.DeepEquals, "name budget set to 5\n")
	s.mockAPI.CheckCall(c, 0, "SetBudget", "name", "5")
}
Exemplo n.º 4
0
Arquivo: commands.go Projeto: bac/juju
// RegisterAll registers all romulus commands with the
// provided command registry.
func RegisterAll(r commandRegister) {
	register := func(c cmd.Command) {
		switch c := c.(type) {
		case modelcmd.ModelCommand:
			r.Register(modelcmd.Wrap(c))
		case modelcmd.CommandBase:
			r.Register(modelcmd.WrapBase(c))
		default:
			r.Register(c)
		}

	}
	register(agree.NewAgreeCommand())
	register(listagreements.NewListAgreementsCommand())
	register(allocate.NewAllocateCommand())
	register(listbudgets.NewListBudgetsCommand())
	register(createbudget.NewCreateBudgetCommand())
	register(listplans.NewListPlansCommand())
	register(setbudget.NewSetBudgetCommand())
	register(setplan.NewSetPlanCommand())
	register(showbudget.NewShowBudgetCommand())
	register(updateallocation.NewUpdateAllocationCommand())
}