Expect(runCommand([]string{"-o", orgName, serviceName})).To(BeTrue()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"OK"}, )) Expect(actor.UpdateOrgForServiceCallCount()).To(Equal(1)) service, org, disable := actor.UpdateOrgForServiceArgsForCall(0) Expect(service).To(Equal(serviceName)) Expect(org).To(Equal(orgName)) Expect(disable).To(BeFalse()) }) }) Context("the user provides a plan and org", func() { It("prints an error if updating the plan fails", func() { actor.UpdatePlanAndOrgForServiceReturns(errors.New("could not find org")) Expect(runCommand([]string{"-p", servicePlanName, "-o", "not-findable-org", serviceName})).To(BeFalse()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"could not find org"}, )) }) It("disables the service plan for the org", func() { Expect(runCommand([]string{"-p", publicServicePlanName, "-o", orgName, serviceName})).To(BeTrue()) Expect(ui.Outputs()).To(ContainSubstrings( []string{"OK"}, )) Expect(actor.UpdatePlanAndOrgForServiceCallCount()).To(Equal(1)) service, plan, org, disable := actor.UpdatePlanAndOrgForServiceArgsForCall(0)
}) It("tells the user the plan is being updated if it is not public", func() { actor.UpdateSinglePlanForServiceReturns(actors.None, nil) Expect(runCommand([]string{"-p", "private-service-plan", "service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"Enabling access of plan private-service-plan for service service"}, []string{"OK"}, )) }) }) Context("the user provides a plan and org", func() { It("fails if the org does not exist", func() { actor.UpdatePlanAndOrgForServiceReturns(actors.All, errors.New("could not find org")) Expect(runCommand([]string{"-p", "service-plan", "-o", "not-findable-org", "service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"could not find org"}, )) }) It("tells the user if the plan is already public", func() { actor.UpdatePlanAndOrgForServiceReturns(actors.All, nil) Expect(runCommand([]string{"-p", "public-service-plan", "-o", "my-org", "service"})).To(BeTrue()) Expect(ui.Outputs).To(ContainSubstrings( []string{"The plan is already accessible for this org"}, []string{"OK"}, ))