Describe("GetRouteApplications", func() { Context("when the CC client returns no errors", func() { BeforeEach(func() { fakeCloudControllerClient.GetRouteApplicationsReturns( []ccv2.Application{ { GUID: "application-guid", Name: "application-name", }, }, ccv2.Warnings{"route-applications-warning"}, nil) }) It("returns the applications bound to the route and warnings", func() { applications, warnings, err := actor.GetRouteApplications("route-guid", nil) Expect(fakeCloudControllerClient.GetRouteApplicationsCallCount()).To(Equal(1)) Expect(fakeCloudControllerClient.GetRouteApplicationsArgsForCall(0)).To(Equal("route-guid")) Expect(err).ToNot(HaveOccurred()) Expect(warnings).To(ConsistOf("route-applications-warning")) Expect(applications).To(ConsistOf( Application{ GUID: "application-guid", Name: "application-name", }, )) }) }) Context("when the CC client returns an error", func() { BeforeEach(func() { fakeCloudControllerClient.GetRouteApplicationsReturns(
}, { GUID: "orphaned-route-guid-2", Domain: "some-other-domain.com", }, })) Expect(fakeCloudControllerClient.GetSpaceRoutesCallCount()).To(Equal(1)) spaceGUID, queries := fakeCloudControllerClient.GetSpaceRoutesArgsForCall(0) Expect(spaceGUID).To(Equal("space-guid")) Expect(queries).To(BeNil()) Expect(fakeCloudControllerClient.GetRouteApplicationsCallCount()).To(Equal(3)) routeGUID, queries := fakeCloudControllerClient.GetRouteApplicationsArgsForCall(0) Expect(routeGUID).To(Equal("orphaned-route-guid-1")) Expect(queries).To(BeNil()) routeGUID, queries = fakeCloudControllerClient.GetRouteApplicationsArgsForCall(1) Expect(routeGUID).To(Equal("orphaned-route-guid-2")) Expect(queries).To(BeNil()) routeGUID, queries = fakeCloudControllerClient.GetRouteApplicationsArgsForCall(2) Expect(routeGUID).To(Equal("not-orphaned-route-guid-3")) Expect(queries).To(BeNil()) }) }) Context("when there are no orphaned routes", func() { var expectedErr OrphanedRoutesNotFoundError