github.com/DaAlbrecht/cf-cli@v0.0.0-20231128151943-1fe19bb400b9/actor/actionerror/service_plan_not_found_error_test.go (about) 1 package actionerror_test 2 3 import ( 4 "fmt" 5 6 "code.cloudfoundry.org/cli/actor/actionerror" 7 . "github.com/onsi/ginkgo" 8 . "github.com/onsi/gomega" 9 ) 10 11 var _ = Describe("ServicePlanNotFoundError", func() { 12 const ( 13 offeringName = "some-service-offering" 14 planName = "some-plan" 15 brokerName = "some-broker" 16 ) 17 18 It("returns a message with the service offering name and the plan name", func() { 19 err := actionerror.ServicePlanNotFoundError{ 20 OfferingName: offeringName, 21 PlanName: planName, 22 } 23 Expect(err.Error()).To(Equal(fmt.Sprintf("The plan %s could not be found for service offering %s.", planName, offeringName))) 24 }) 25 26 It("returns a message with the service offering name, the plan name and broker name", func() { 27 err := actionerror.ServicePlanNotFoundError{ 28 OfferingName: offeringName, 29 PlanName: planName, 30 ServiceBrokerName: brokerName, 31 } 32 Expect(err.Error()).To(Equal(fmt.Sprintf( 33 "The plan %s could not be found for service offering %s and broker %s.", 34 planName, 35 offeringName, 36 brokerName, 37 ))) 38 }) 39 40 When("no service offering name", func() { 41 It("returns a message with the plan name", func() { 42 err := actionerror.ServicePlanNotFoundError{ 43 PlanName: "some-plan", 44 } 45 Expect(err.Error()).To(Equal("Service plan 'some-plan' not found.")) 46 }) 47 }) 48 49 When("no plan name", func() { 50 It("returns a message with the offering name", func() { 51 err := actionerror.ServicePlanNotFoundError{ 52 OfferingName: "some-service", 53 } 54 Expect(err.Error()).To(Equal("No service plans found for service offering 'some-service'.")) 55 }) 56 }) 57 58 When("no names", func() { 59 It("returns generic message", func() { 60 err := actionerror.ServicePlanNotFoundError{} 61 Expect(err.Error()).To(Equal("No service plans found.")) 62 }) 63 }) 64 })