Context("when the route can be found", func() { BeforeEach(func() { routeRepo.FindReturns(models.Route{Guid: "route-guid"}, nil) }) Context("when the service instance is not user-provided and requires route forwarding", func() { BeforeEach(func() { serviceInstance := models.ServiceInstance{ ServiceOffering: models.ServiceOfferingFields{ Requires: []string{"route_forwarding"}, }, } serviceInstance.ServicePlan = models.ServicePlanFields{ Guid: "service-plan-guid", } serviceInstanceRequirement.GetServiceInstanceReturns(serviceInstance) }) It("asks the user to confirm", func() { ui.Inputs = []string{"n"} cmd.Execute(flagContext) Expect(ui.Prompts).To(ContainSubstrings( []string{"Binding may cause requests for route", "Do you want to proceed?"}, )) }) Context("when the user confirms", func() { JustBeforeEach(func() { defer func() { recover() }() ui.Inputs = []string{"y"} cmd.Execute(flagContext)
}) }) Describe("Execute", func() { BeforeEach(func() { err := flagContext.Parse("service-instance") Expect(err).NotTo(HaveOccurred()) _, err = cmd.Requirements(factory, flagContext) Expect(err).NotTo(HaveOccurred()) }) Context("when the service instance is not user-provided", func() { BeforeEach(func() { serviceInstanceRequirement.GetServiceInstanceReturns(models.ServiceInstance{ ServicePlan: models.ServicePlanFields{ Guid: "service-plan-guid", }, }) }) It("fails with error", func() { Expect(func() { cmd.Execute(flagContext) }).To(Panic()) Expect(ui.Outputs).To(ContainSubstrings( []string{"FAILED"}, []string{"Service Instance is not user provided"}, )) }) }) Context("when the service instance is user-provided", func() { var serviceInstance models.ServiceInstance