Beispiel #1
0
	cmd := NewCreateService(fakeUI, config, serviceRepo)
	reqFactory := &testreq.FakeReqFactory{}

	testcmd.RunCommand(cmd, ctxt, reqFactory)
	return
}

var _ = Describe("create-service command", func() {
	It("successfully creates a service", func() {
		offering := models.ServiceOffering{}
		offering.Label = "cleardb"
		plan := models.ServicePlanFields{}
		plan.Name = "spark"
		plan.Guid = "cleardb-spark-guid"
		offering.Plans = []models.ServicePlanFields{plan}
		offering2 := models.ServiceOffering{}
		offering2.Label = "postgres"

		serviceRepo := &testapi.FakeServiceRepo{}
		serviceRepo.FindServiceOfferingsForSpaceByLabelReturns.ServiceOfferings = []models.ServiceOffering{
			offering,
			offering2,
		}

		ui := callCreateService([]string{"cleardb", "spark", "my-cleardb-service"},
			[]string{},
			serviceRepo,
		)

		testassert.SliceContains(ui.Outputs, testassert.Lines{
Beispiel #2
0
		offering1 models.ServiceOffering
		offering2 models.ServiceOffering
	)

	BeforeEach(func() {
		ui = &testterm.FakeUI{}
		config = testconfig.NewRepositoryWithDefaults()
		reqFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true}
		serviceRepo = &testapi.FakeServiceRepo{}
		cmd = NewCreateService(ui, config, serviceRepo)

		offering1 = models.ServiceOffering{}
		offering1.Label = "cleardb"
		offering1.Plans = []models.ServicePlanFields{{
			Name: "spark",
			Guid: "cleardb-spark-guid",
		}}

		offering2 = models.ServiceOffering{}
		offering2.Label = "postgres"

		serviceRepo.FindServiceOfferingsForSpaceByLabelReturns.ServiceOfferings = []models.ServiceOffering{offering1, offering2}
	})

	var callCreateService = func(args []string) {
		ctxt := testcmd.NewContext("create-service", args)
		testcmd.RunCommand(cmd, ctxt, reqFactory)
	}

	Describe("requirements", func() {
		It("passes when logged in and a space is targeted", func() {