Context("when the named service exists", func() { It("disables the service", func() { Expect(runCommand([]string{serviceName})).To(BeTrue()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"OK"}, )) Expect(actor.UpdateAllPlansForServiceCallCount()).To(Equal(1)) service, disable := actor.UpdateAllPlansForServiceArgsForCall(0) 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"}, ))
[]string{"Refreshing went wrong"}, []string{"FAILED"}, )) }) }) Context("when the named service exists", func() { It("returns OK when ran successfully", func() { Expect(runCommand([]string{"service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"OK"}, )) }) It("tells the user if all plans were already public", func() { actor.UpdateAllPlansForServiceReturns(true, nil) Expect(runCommand([]string{"service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"All plans of the service", "are already accessible for all orgs"}, []string{"OK"}, )) }) It("tells the user the plans are being updated if they weren't all already public", func() { actor.UpdateAllPlansForServiceReturns(false, nil) Expect(runCommand([]string{"service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"Enabling access to all plans of service service for all orgs as my-user..."}, []string{"OK"},