func (s *allocateSuite) TestAllocateErrors(c *gc.C) { tests := []struct { about string args []string expectedError string }{{ about: "no args", args: []string{}, expectedError: "budget and service name required", }, { about: "budget without allocation limit", args: []string{"name", "db"}, expectedError: "invalid budget specification, expecting <budget>:<limit>", }, { about: "service not specified", args: []string{"name:100"}, expectedError: "budget and service name required", }} for i, test := range tests { c.Logf("test %d: %s", i, test.about) set := allocate.NewAllocateCommand() _, err := cmdtesting.RunCommand(c, set, test.args...) c.Check(err, gc.ErrorMatches, test.expectedError) s.mockAPI.CheckNoCalls(c) } }
func (s *allocateSuite) TestallocateAPIError(c *gc.C) { s.stub.SetErrors(errors.New("something failed")) set := allocate.NewAllocateCommand() _, err := cmdtesting.RunCommand(c, set, "name:100", "db") c.Assert(err, gc.ErrorMatches, "failed to create allocation: something failed") s.mockAPI.CheckCall(c, 0, "CreateAllocation", "name", "100", "env-uuid", []string{"db"}) }
func (s *allocateSuite) TestAllocate(c *gc.C) { s.mockAPI.resp = "allocation updated" alloc := allocate.NewAllocateCommand() ctx, err := cmdtesting.RunCommand(c, alloc, "name:100", "db") c.Assert(err, jc.ErrorIsNil) c.Assert(cmdtesting.Stdout(ctx), jc.DeepEquals, "allocation updated") s.mockAPI.CheckCall(c, 0, "CreateAllocation", "name", "100", "env-uuid", []string{"db"}) }
// RegisterAll registers all romulus commands with the // provided command registry. func RegisterAll(r commandRegister) { r.Register(agree.NewAgreeCommand()) r.Register(allocate.NewAllocateCommand()) r.Register(createbudget.NewCreateBudgetCommand()) r.Register(listbudgets.NewListBudgetsCommand()) r.Register(listplans.NewListPlansCommand()) r.Register(setbudget.NewSetBudgetCommand()) r.Register(setplan.NewSetPlanCommand()) r.Register(showbudget.NewShowBudgetCommand()) r.Register(updateallocation.NewUpdateAllocationCommand()) }
// 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()) }