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.GetServiceByNameWithPlansReturns(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.GetServiceByNameWithPlansReturns(mixedService, nil) err := actor.UpdateAllPlansForService("my-mixed-service", true) Expect(err).ToNot(HaveOccurred())
orgRepo = new(organizationsfakes.FakeOrganizationRepository) builder = planbuilder.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": {plan1, plan2}, } org1 = models.Organization{} org1.Name = "org1" org1.GUID = "org1-guid" org2 = models.Organization{} org2.Name = "org2" org2.GUID = "org2-guid" visibilityRepo.ListReturns([]models.ServicePlanVisibilityFields{ {ServicePlanGUID: "service-plan1-guid", OrganizationGUID: "org1-guid"}, {ServicePlanGUID: "service-plan1-guid", OrganizationGUID: "org2-guid"}, {ServicePlanGUID: "service-plan2-guid", OrganizationGUID: "org1-guid"}, }, nil) orgRepo.GetManyOrgsByGUIDReturns([]models.Organization{org1, org2}, nil) })