Пример #1
0
			testcmd.RunCommand(
				NewPurgeServiceOffering(deps.ui, deps.config, deps.serviceRepo),
				testcmd.NewContext("purge-service-offering", []string{}),
				deps.reqFactory,
			)

			Expect(testcmd.CommandDidPassRequirements).To(BeFalse())
			Expect(deps.ui.FailedWithUsage).To(BeTrue())
			Expect(deps.ui.FailedWithUsageCommandName).To(Equal("purge-service-offering"))
		})
	})

	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),
			testcmd.NewContext("purge-service-offering", []string{"-p", "the-provider", "the-service-name"}),
			deps.reqFactory,
		)

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

	It("purges service offerings", func() {
		testServer, handler, repo := createServiceRepo([]testnet.TestRequest{{
			Method: "DELETE",
			Path:   "/v2/services/the-service-guid?purge=true",
			Response: testnet.TestResponse{
				Status: 204,
			},
		}})
		defer testServer.Close()

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

		apiErr := repo.PurgeServiceOffering(offering)
		Expect(apiErr).NotTo(HaveOccurred())
		Expect(handler).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() {
			req := testapi.NewCloudControllerTestRequest(testnet.TestRequest{
				Method: "GET",
				Path:   fmt.Sprintf("/v2/service_plans/%s/service_instances?results-per-page=1", planGuid),
				Response: testnet.TestResponse{Status: http.StatusOK, Body: `