Expect(service).To(Equal(serviceName)) Expect(disable).To(BeFalse()) }) It("prints an error if updating the plans fails", func() { actor.UpdateAllPlansForServiceReturns(errors.New("Kaboom!")) Expect(runCommand([]string{serviceName})).To(BeFalse()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"Kaboom!"}, )) }) Context("The user provides a plan", func() { It("prints an error if updating the plan fails", func() { actor.UpdateSinglePlanForServiceReturns(errors.New("could not find service")) Expect(runCommand([]string{"-p", servicePlanName, serviceName})).To(BeFalse()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"could not find service"}, )) }) It("disables the plan", func() { Expect(runCommand([]string{"-p", publicServicePlanName, serviceName})).To(BeTrue()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"OK"}, )) Expect(actor.UpdateSinglePlanForServiceCallCount()).To(Equal(1)) service, plan, disable := actor.UpdateSinglePlanForServiceArgsForCall(0)
[]string{"OK"}, )) }) It("prints an error if updating one of the plans fails", func() { actor.UpdateAllPlansForServiceReturns(true, errors.New("Kaboom!")) Expect(runCommand([]string{"service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"Kaboom!"}, )) }) Context("The user provides a plan", func() { It("prints an error if the service does not exist", func() { actor.UpdateSinglePlanForServiceReturns(actors.All, errors.New("could not find service")) Expect(runCommand([]string{"-p", "service-plan", "service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"could not find service"}, )) }) It("tells the user if the plan is already public", func() { actor.UpdateSinglePlanForServiceReturns(actors.All, nil) Expect(runCommand([]string{"-p", "public-service-plan", "service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"The plan is already accessible for all orgs"}, []string{"OK"}, ))