expectedRouteOverrides := app_runner.RouteOverrides{ {HostnamePrefix: "foo.com", Port: 8080}, {HostnamePrefix: "bar", Port: 9090}, } err := appRunner.UpdateAppRoutes("americano-app", expectedRouteOverrides) Expect(err).NotTo(HaveOccurred()) Expect(fakeReceptorClient.UpdateDesiredLRPCallCount()).To(Equal(1)) processGuid, updateRequest := fakeReceptorClient.UpdateDesiredLRPArgsForCall(0) Expect(processGuid).To(Equal("americano-app")) expectedRoutes := route_helpers.AppRoutes{ {Hostnames: []string{"foo.com"}, Port: 8080}, {Hostnames: []string{"bar.myDiegoInstall.com"}, Port: 9090}, } Expect(route_helpers.AppRoutesFromRoutingInfo(updateRequest.Routes)).To(ContainExactly(expectedRoutes)) }) Context("when an empty routes is passed", func() { It("deregisters the routes", func() { desiredLRPs := []receptor.DesiredLRPResponse{receptor.DesiredLRPResponse{ProcessGuid: "americano-app"}} fakeReceptorClient.DesiredLRPsReturns(desiredLRPs, nil) err := appRunner.UpdateAppRoutes("americano-app", app_runner.RouteOverrides{}) Expect(err).NotTo(HaveOccurred()) Expect(fakeReceptorClient.UpdateDesiredLRPCallCount()).To(Equal(1)) processGuid, updateRequest := fakeReceptorClient.UpdateDesiredLRPArgsForCall(0) Expect(processGuid).To(Equal("americano-app")) Expect(updateRequest.Routes).To(Equal(route_helpers.AppRoutes{}.RoutingInfo())) })
Expect(err).NotTo(HaveOccurred()) Expect(payload).To(MatchJSON(`[]`)) }) }) }) }) Describe("AppRoutesFromRoutingInfo", func() { var routingInfo receptor.RoutingInfo Context("when the method returns a value", func() { var routesResult route_helpers.AppRoutes JustBeforeEach(func() { routesResult = route_helpers.AppRoutesFromRoutingInfo(routingInfo) }) Context("when lattice app routes are present in the routing info", func() { BeforeEach(func() { routingInfo = appRoutes.RoutingInfo() }) It("returns the routes", func() { Expect(appRoutes).To(Equal(routesResult)) }) }) Context("when the result should be nil", func() { itReturnsNilRoutes := func() { It("returns nil routes", func() {