serviceRepo.FindServiceOfferingByLabelAndProviderApiResponse = cferrors.NewWithError("oh no!", errors.New("!"))

		runCommand(
			[]string{"-f", "-p", "the-provider", "the-service-name"},
		)

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"FAILED"},
			[]string{"oh no!"},
		))

		Expect(serviceRepo.PurgeServiceOfferingCalled).To(Equal(false))
	})

	It("fails with an error message when the purging request fails", func() {
		serviceRepo.PurgeServiceOfferingApiResponse = cferrors.New("crumpets insufficiently buttered")

		runCommand(
			[]string{"-f", "-p", "the-provider", "the-service-name"},
		)

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"FAILED"},
			[]string{"crumpets insufficiently buttered"},
		))
	})

	It("indicates when a service doesn't exist", func() {
		serviceRepo.FindServiceOfferingByLabelAndProviderApiResponse = cferrors.NewModelNotFoundError("Service Offering", "")

		ui.Inputs = []string{"yes"}
예제 #2
0
		serviceRepo.FindServiceOfferingByLabelAndProviderApiResponse = fmt.Errorf("%s: %s", "oh no!", errors.New("!").Error())

		runCommand(
			[]string{"-f", "-p", "the-provider", "the-service-name"},
		)

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"FAILED"},
			[]string{"oh no!"},
		))

		Expect(serviceRepo.PurgeServiceOfferingCalled).To(Equal(false))
	})

	It("fails with an error message when the purging request fails", func() {
		serviceRepo.PurgeServiceOfferingApiResponse = fmt.Errorf("crumpets insufficiently buttered")

		runCommand(
			[]string{"-f", "-p", "the-provider", "the-service-name"},
		)

		Expect(ui.Outputs).To(ContainSubstrings(
			[]string{"FAILED"},
			[]string{"crumpets insufficiently buttered"},
		))
	})

	It("indicates when a service doesn't exist", func() {
		serviceRepo.FindServiceOfferingByLabelAndProviderApiResponse = cferrors.NewModelNotFoundError("Service Offering", "")

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