BeforeEach(func() { routingApiServer = ghttp.NewServer() routingApiServer.RouteToHandler("GET", "/v1/router_groups", func(w http.ResponseWriter, req *http.Request) { responseBody := []byte(`[ { "guid": "bad25cff-9332-48a6-8603-b619858e7992", "name": "default-tcp", "type": "tcp" }]`) w.Header().Set("Content-Length", strconv.Itoa(len(responseBody))) w.Header().Set("Content-Type", "application/json") w.WriteHeader(http.StatusOK) w.Write(responseBody) }) configRepo.SetRoutingApiEndpoint(routingApiServer.URL()) }) It("lists routing groups", func() { cb := func(grp models.RouterGroup) bool { Expect(grp).To(Equal(models.RouterGroup{ Guid: "bad25cff-9332-48a6-8603-b619858e7992", Name: "default-tcp", Type: "tcp", })) return true } err := repo.ListRouterGroups(cb) Expect(err).ToNot(HaveOccurred()) }) })
}) It("prints the domain information", func() { cmd.Execute(flagContext) Expect(ui.Outputs).To(BeInDisplayOrder( []string{"name", "status", "type"}, []string{"Shared-domain1", "shared"}, []string{"Private-domain1", "owned"}, )) }) Context("when routing api endpoint is not set", func() { var originalRoutingApiEndpoint string BeforeEach(func() { originalRoutingApiEndpoint = configRepo.RoutingApiEndpoint() configRepo.SetRoutingApiEndpoint("") }) AfterEach(func() { configRepo.SetRoutingApiEndpoint(originalRoutingApiEndpoint) }) It("does not panic", func() { Expect(func() { cmd.Execute(flagContext) }).NotTo(Panic()) }) Context("when returned domain has a router-group-guid", func() { BeforeEach(func() { domainFields = []models.DomainFields{ models.DomainFields{ Shared: true,
var _ = Describe("RoutingApi", func() { var ( ui *testterm.FakeUI config core_config.Repository requirement requirements.RoutingAPIRequirement ) BeforeEach(func() { ui = new(testterm.FakeUI) config = testconfig.NewRepositoryWithAccessToken(core_config.TokenInfo{Username: "******"}) requirement = requirements.NewRoutingAPIRequirement(ui, config) }) Context("when the config has a zero-length RoutingApiEndpoint", func() { BeforeEach(func() { config.SetRoutingApiEndpoint("") }) It("panics and prints a failure message", func() { Expect(func() { requirement.Execute() }).To(Panic()) Expect(ui.Outputs).To(ContainElement("Routing API URI missing. Please log in again to set the URI automatically.")) }) }) Context("when the config has a RoutingApiEndpoint", func() { BeforeEach(func() { config.SetRoutingApiEndpoint("api.example.com") }) It("does not print anything", func() { requirement.Execute()