testcmd.RunCommand(
				NewPurgeServiceOffering(deps.ui, deps.config, deps.serviceRepo),
				[]string{},
				deps.requirementsFactory,
			)

			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
			Expect(deps.ui.FailedWithUsage).To(BeTrue())
		})
	})

	It("works when given -p and a provider name", func() {
		deps := setupDependencies()

		offering := maker.NewServiceOffering("the-service-name")
		deps.serviceRepo.FindServiceOfferingByLabelAndProviderServiceOffering = offering

		deps.ui.Inputs = []string{"yes"}

		testcmd.RunCommand(
			NewPurgeServiceOffering(deps.ui, deps.config, deps.serviceRepo),
			[]string{"-p", "the-provider", "the-service-name"},
			deps.requirementsFactory,
		)

		Expect(deps.serviceRepo.FindServiceOfferingByLabelAndProviderName).To(Equal("the-service-name"))
		Expect(deps.serviceRepo.FindServiceOfferingByLabelAndProviderProvider).To(Equal("the-provider"))
		Expect(deps.serviceRepo.PurgedServiceOffering).To(Equal(offering))
	})
Exemple #2
0
			_, err := repo.FindServiceOfferingByLabelAndProvider("offering-1", "provider-1")
			Expect(err).To(HaveOccurred())
			Expect(err.(errors.HttpError).ErrorCode()).To(Equal("10005"))
		})
	})

	Describe("PurgeServiceOffering", func() {
		It("purges service offerings", func() {
			setupTestServer(testnet.TestRequest{
				Method: "DELETE",
				Path:   "/v2/services/the-service-guid?purge=true",
				Response: testnet.TestResponse{
					Status: 204,
				}})

			offering := maker.NewServiceOffering("the-offering")
			offering.Guid = "the-service-guid"

			err := repo.PurgeServiceOffering(offering)
			Expect(err).NotTo(HaveOccurred())
			Expect(testHandler).To(testnet.HaveAllRequestsCalled())
		})
	})

	Describe("getting the count of service instances for a service plan", func() {
		var planGuid = "abc123"

		It("returns the number of service instances", func() {
			setupTestServer(testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "GET",
				Path:   fmt.Sprintf("/v2/service_plans/%s/service_instances?results-per-page=1", planGuid),