コード例 #1
0
ファイル: allocate_test.go プロジェクト: tasdomas/romulus-1
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)
	}
}
コード例 #2
0
ファイル: allocate_test.go プロジェクト: tasdomas/romulus-1
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"})
}
コード例 #3
0
ファイル: allocate_test.go プロジェクト: tasdomas/romulus-1
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"})
}
コード例 #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())
}