Exemplo n.º 1
0
	})
	It("TestRenameServiceRequirements", func() {

		requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: false, TargetedSpaceSuccess: true}
		callRenameService([]string{"my-service", "new-name"}, requirementsFactory)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		requirementsFactory = &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: false}
		callRenameService([]string{"my-service", "new-name"}, requirementsFactory)
		Expect(testcmd.CommandDidPassRequirements).To(BeFalse())

		Expect(requirementsFactory.ServiceInstanceName).To(Equal("my-service"))
	})
	It("TestRenameService", func() {

		serviceInstance := models.ServiceInstance{}
		serviceInstance.Name = "different-name"
		serviceInstance.Guid = "different-name-guid"
		requirementsFactory := &testreq.FakeReqFactory{LoginSuccess: true, TargetedSpaceSuccess: true, ServiceInstance: serviceInstance}
		ui, fakeServiceRepo := callRenameService([]string{"my-service", "new-name"}, requirementsFactory)

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Renaming service", "different-name", "new-name", "my-org", "my-space", "my-user"},
			{"OK"},
		})

		Expect(fakeServiceRepo.RenameServiceServiceInstance).To(Equal(serviceInstance))
		Expect(fakeServiceRepo.RenameServiceNewName).To(Equal("new-name"))
	})
})
Exemplo n.º 2
0
		ts, handler, repo := createServiceBindingRepo([]testnet.TestRequest{req})
		defer ts.Close()

		apiErr := repo.Create("my-service-instance-guid", "my-app-guid")

		Expect(handler).To(testnet.HaveAllRequestsCalled())
		Expect(apiErr).NotTo(BeNil())
		Expect(apiErr.ErrorCode()).To(Equal("90003"))
	})

	It("TestDeleteServiceBinding", func() {
		ts, handler, repo := createServiceBindingRepo([]testnet.TestRequest{deleteBindingReq})
		defer ts.Close()

		serviceInstance := models.ServiceInstance{}
		serviceInstance.Guid = "my-service-instance-guid"

		binding := models.ServiceBindingFields{}
		binding.Url = "/v2/service_bindings/service-binding-1-guid"
		binding.AppGuid = "app-1-guid"
		binding2 := models.ServiceBindingFields{}
		binding2.Url = "/v2/service_bindings/service-binding-2-guid"
		binding2.AppGuid = "app-2-guid"
		serviceInstance.ServiceBindings = []models.ServiceBindingFields{binding, binding2}

		found, apiErr := repo.Delete(serviceInstance, "app-2-guid")

		Expect(handler).To(testnet.HaveAllRequestsCalled())
		Expect(apiErr).NotTo(HaveOccurred())
		Expect(found).To(BeTrue())
	})
Exemplo n.º 3
0
		Expect(ui.FailedWithUsage).To(BeFalse())
	})
	It("TestShowServiceOutput", func() {

		offering := models.ServiceOfferingFields{}
		offering.Label = "mysql"
		offering.DocumentationUrl = "http://documentation.url"
		offering.Description = "the-description"

		plan := models.ServicePlanFields{}
		plan.Guid = "plan-guid"
		plan.Name = "plan-name"

		serviceInstance := models.ServiceInstance{}
		serviceInstance.Name = "service1"
		serviceInstance.Guid = "service1-guid"
		serviceInstance.ServicePlan = plan
		serviceInstance.ServiceOffering = offering
		reqFactory := &testreq.FakeReqFactory{
			LoginSuccess:         true,
			TargetedSpaceSuccess: true,
			ServiceInstance:      serviceInstance,
		}
		ui := callShowService([]string{"service1"}, reqFactory)

		testassert.SliceContains(ui.Outputs, testassert.Lines{
			{"Service instance:", "service1"},
			{"Service: ", "mysql"},
			{"Plan: ", "plan-name"},
			{"Description: ", "the-description"},
			{"Documentation url: ", "http://documentation.url"},