func (resource RouteSummary) ToModel() (route models.RouteSummary) { domain := models.DomainFields{} domain.Guid = resource.Domain.Guid domain.Name = resource.Domain.Name domain.Shared = resource.Domain.OwningOrganizationGuid != "" route.Guid = resource.Guid route.Host = resource.Host route.Domain = domain return }
Expect(handler).To(HaveAllRequestsCalled()) Expect(apiErr).NotTo(HaveOccurred()) }) It("finds a route by host and domain", func() { ts, handler = testnet.NewServer([]testnet.TestRequest{ testapi.NewCloudControllerTestRequest(testnet.TestRequest{ Method: "GET", Path: "/v2/routes?q=host%3Amy-cool-app%3Bdomain_guid%3Amy-domain-guid", Response: findRouteByHostResponse, }), }) configRepo.SetApiEndpoint(ts.URL) domain := models.DomainFields{} domain.Guid = "my-domain-guid" route, apiErr := repo.FindByHostAndDomain("my-cool-app", domain) Expect(apiErr).NotTo(HaveOccurred()) Expect(handler).To(HaveAllRequestsCalled()) Expect(route.Host).To(Equal("my-cool-app")) Expect(route.Guid).To(Equal("my-route-guid")) Expect(route.Domain.Guid).To(Equal(domain.Guid)) }) It("returns 'not found' response when there is no route w/ the given domain and host", func() { ts, handler = testnet.NewServer([]testnet.TestRequest{ testapi.NewCloudControllerTestRequest(testnet.TestRequest{ Method: "GET", Path: "/v2/routes?q=host%3Amy-cool-app%3Bdomain_guid%3Amy-domain-guid",
}) }) Context("when logged in and an org is targeted", func() { BeforeEach(func() { org := models.OrganizationFields{} org.Name = "my-org" app := models.ApplicationFields{} app.Name = "app1" app.Guid = "app1-guid" apps := []models.ApplicationFields{app} domain := models.DomainFields{} domain.Name = "domain1" domain.Guid = "domain1-guid" domains := []models.DomainFields{domain} serviceInstance := models.ServiceInstanceFields{} serviceInstance.Name = "service1" serviceInstance.Guid = "service1-guid" services := []models.ServiceInstanceFields{serviceInstance} securityGroup1 := models.SecurityGroupFields{Name: "Nacho Security"} securityGroup2 := models.SecurityGroupFields{Name: "Nacho Prime"} securityGroups := []models.SecurityGroupFields{securityGroup1, securityGroup2} space := models.Space{} space.Name = "whose-space-is-it-anyway" space.Organization = org space.Applications = apps