orgRepo = &testorg.FakeOrganizationRepository{} builder = plan_builder.NewBuilder(planRepo, visibilityRepo, orgRepo) plan1 = models.ServicePlanFields{ Name: "service-plan1", Guid: "service-plan1-guid", ServiceOfferingGuid: "service-guid1", } plan2 = models.ServicePlanFields{ Name: "service-plan2", Guid: "service-plan2-guid", ServiceOfferingGuid: "service-guid1", } planRepo.SearchReturns = map[string][]models.ServicePlanFields{ "service-guid1": []models.ServicePlanFields{plan1, plan2}, } org1 = models.Organization{} org1.Name = "org1" org1.Guid = "org1-guid" org2 = models.Organization{} org2.Name = "org2" org2.Guid = "org2-guid" /** orgRepo.Organizations = []models.Organization{ org1, org2, } **/ visibilityRepo.ListReturns([]models.ServicePlanVisibilityFields{
visibility1 = models.ServicePlanVisibilityFields{ Guid: "visibility-guid-1", OrganizationGuid: "org-1-guid", ServicePlanGuid: "limited-service-plan-guid", } }) Describe(".UpdateAllPlansForService", func() { BeforeEach(func() { servicePlanVisibilityRepo.SearchReturns( []models.ServicePlanVisibilityFields{privateServicePlanVisibilityFields}, nil) servicePlanRepo.SearchReturns = map[string][]models.ServicePlanFields{ "my-mixed-service-guid": { publicServicePlan, privateServicePlan, }, } }) It("Returns an error if the service cannot be found", func() { serviceBuilder.GetServiceByNameReturns(models.ServiceOffering{}, errors.New("service was not found")) _, err := actor.UpdateAllPlansForService("not-a-service", true) Expect(err.Error()).To(Equal("service was not found")) }) It("Removes the service plan visibilities for any non-public service plans", func() { serviceBuilder.GetServiceByNameReturns(mixedService, nil) _, err := actor.UpdateAllPlansForService("my-mixed-service", true) Expect(err).ToNot(HaveOccurred())