コード例 #1
0
func (s *updateAllocationSuite) TestUpdateAllocationAPIError(c *gc.C) {
	s.stub.SetErrors(errors.New("something failed"))
	set := updateallocation.NewUpdateAllocationCommand()
	_, err := cmdtesting.RunCommand(c, set, "name", "5")
	c.Assert(err, gc.ErrorMatches, "failed to update the allocation: something failed")
	s.mockAPI.CheckCall(c, 0, "UpdateAllocation", "env-uuid", "name", "5")
}
コード例 #2
0
func (s *updateAllocationSuite) TestUpdateAllocationErrors(c *gc.C) {
	tests := []struct {
		about         string
		args          []string
		expectedError string
	}{
		{
			about:         "value needs to be a number",
			args:          []string{"name", "badvalue"},
			expectedError: "value needs to be a whole number",
		},
		{
			about:         "value is missing",
			args:          []string{"name"},
			expectedError: "service and value required",
		},
		{
			about:         "no args",
			args:          []string{},
			expectedError: "service and value required",
		},
	}
	for i, test := range tests {
		s.mockAPI.ResetCalls()
		c.Logf("test %d: %s", i, test.about)
		set := updateallocation.NewUpdateAllocationCommand()
		_, err := cmdtesting.RunCommand(c, set, test.args...)
		c.Check(err, gc.ErrorMatches, test.expectedError)
		s.mockAPI.CheckNoCalls(c)
	}
}
コード例 #3
0
func (s *updateAllocationSuite) TestUpdateAllocation(c *gc.C) {
	s.mockAPI.resp = "name budget set to 5"
	set := updateallocation.NewUpdateAllocationCommand()
	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")
	s.mockAPI.CheckCall(c, 0, "UpdateAllocation", "env-uuid", "name", "5")
}
コード例 #4
0
ファイル: commands.go プロジェクト: tasdomas/romulus-1
// 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())
}
コード例 #5
0
ファイル: commands.go プロジェクト: alesstimec/romulus-1
// 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())
}