Exemple #1
0
func (appRunner *appRunner) buildRoutesWithDefaults(params CreateAppParams, primaryPort uint16) route_helpers.Routes {
	routes := appRunner.buildRoutes(params.NoRoutes, params.RouteOverrides, params.TcpRoutes)

	if len(routes.AppRoutes) == 0 && len(routes.TcpRoutes) == 0 && !params.NoRoutes {
		routes.AppRoutes = route_helpers.BuildDefaultRoutingInfo(params.Name, params.ExposedPorts, primaryPort, appRunner.systemDomain)
	}

	return routes
}
				Expect(returnPort).To(Equal(uint16(1000)))
			})
		})

		Context("when there is monitor port, and the exposedPorts is empty", func() {
			It("return the monitor port", func() {
				returnPort := route_helpers.GetPrimaryPort(uint16(1000), []uint16{})
				Expect(returnPort).To(Equal(uint16(1000)))
			})
		})
	})

	Describe("BuildDefaultRoutingInfo", func() {
		Context("when no exposedPorts is given", func() {
			It("output empty approutes", func() {
				appRoutes := route_helpers.BuildDefaultRoutingInfo("cool-app", []uint16{}, 5000, "cool-app-domain")
				Expect(appRoutes).To(BeEmpty())
			})
		})

		Context("when primaryPort is not included in the exposedPorts", func() {
			It("doesn't output the default route", func() {
				expectedAppRoutes := route_helpers.AppRoutes{
					{Hostnames: []string{"cool-app-2000.cool-app-domain"}, Port: 2000},
				}
				appRoutes := route_helpers.BuildDefaultRoutingInfo("cool-app", []uint16{2000}, 5000, "cool-app-domain")
				Expect(appRoutes).To(Equal(expectedAppRoutes))
			})
		})

		Context("when primaryPort is included in the exposedPorts", func() {