當前位置: 首頁>>代碼示例>>Golang>>正文


Golang FakeRouteRepository.FindReturns方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/cli/cf/api/apifakes.FakeRouteRepository.FindReturns方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeRouteRepository.FindReturns方法的具體用法?Golang FakeRouteRepository.FindReturns怎麽用?Golang FakeRouteRepository.FindReturns使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/cli/cf/api/apifakes.FakeRouteRepository的用法示例。


在下文中一共展示了FakeRouteRepository.FindReturns方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

					Expect(err).NotTo(HaveOccurred())
					cmd.Requirements(factory, flagContext)
				})

				It("tries to find the route with the port", func() {
					Expect(err).NotTo(HaveOccurred())
					Expect(routeRepo.FindCallCount()).To(Equal(1))
					_, _, _, port := routeRepo.FindArgsForCall(0)
					Expect(port).To(Equal(60000))
				})
			})

			Context("when the route can be found", func() {
				BeforeEach(func() {
					routeRepo.FindReturns(models.Route{
						GUID: "route-guid",
					}, nil)
				})

				It("tries to delete the route", func() {
					Expect(err).NotTo(HaveOccurred())
					Expect(routeRepo.DeleteCallCount()).To(Equal(1))
					Expect(routeRepo.DeleteArgsForCall(0)).To(Equal("route-guid"))
				})

				Context("when deleting the route succeeds", func() {
					BeforeEach(func() {
						routeRepo.DeleteReturns(nil)
					})

					It("tells the user that it succeeded", func() {
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:delete_route_test.go

示例2:

				err := flagContext.Parse("app-name", "domain-name", "--port", "60000")
				Expect(err).NotTo(HaveOccurred())
				cmd.Requirements(factory, flagContext)
			})

			It("tries to find the route with the port", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(routeRepo.FindCallCount()).To(Equal(1))
				_, _, _, port := routeRepo.FindArgsForCall(0)
				Expect(port).To(Equal(60000))
			})
		})

		Context("when the route can be found", func() {
			BeforeEach(func() {
				routeRepo.FindReturns(models.Route{GUID: "route-guid"}, nil)
			})

			It("tells the user that it is removing the route", func() {
				Expect(err).NotTo(HaveOccurred())
				Expect(ui.Outputs()).To(ContainSubstrings(
					[]string{"Removing route", "from app", "in org"},
				))
			})

			Context("when the returned route has an app with the requested app's guid", func() {
				BeforeEach(func() {
					route := models.Route{
						GUID: "route-guid",
						Apps: []models.ApplicationFields{
							{GUID: "fake-app-guid"},
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:31,代碼來源:unmap_route_test.go

示例3:

				Expect(err).NotTo(HaveOccurred())
				ui.Inputs = []string{"n"}
			})

			It("should attempt to find the route", func() {
				Expect(runCLIErr).NotTo(HaveOccurred())
				Expect(routeRepo.FindCallCount()).To(Equal(1))
				hostname, _, path, _ := routeRepo.FindArgsForCall(0)
				Expect(hostname).To(Equal("the-hostname"))
				Expect(path).To(Equal("/path"))
			})
		})

		Context("when the route can be found", func() {
			BeforeEach(func() {
				routeRepo.FindReturns(models.Route{GUID: "route-guid"}, nil)
				ui.Inputs = []string{"n"}
			})

			It("asks the user to confirm", func() {
				Expect(runCLIErr).NotTo(HaveOccurred())
				Expect(ui.Prompts).To(ContainSubstrings(
					[]string{"Unbinding may leave apps mapped to route", "Do you want to proceed?"},
				))
			})

			Context("when the user confirms", func() {
				BeforeEach(func() {
					ui.Inputs = []string{"y"}
				})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:unbind_route_service_test.go

示例4:

			})

			It("attempts to find the route", func() {
				Expect(err).To(HaveOccurred())
				Expect(routeRepo.FindCallCount()).To(Equal(1))

				host, domain, path, port := routeRepo.FindArgsForCall(0)
				Expect(host).To(Equal("hostname"))
				Expect(domain.Name).To(Equal("domain-name"))
				Expect(path).To(Equal("/path"))
				Expect(port).To(Equal(9090))
			})

			Context("when finding the route fails", func() {
				BeforeEach(func() {
					routeRepo.FindReturns(models.Route{}, errors.New("find-error"))
				})

				It("fails with the original error", func() {
					Expect(err).To(HaveOccurred())
					Expect(err.Error()).To(Equal("create-error"))
				})
			})

			Context("when a route with the same space guid, but different domain guid is found", func() {
				It("fails with the original error", func() {
					Expect(err).To(HaveOccurred())
					Expect(err.Error()).To(Equal("create-error"))
				})
			})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:30,代碼來源:create_route_test.go

示例5:

			expectedDomain = models.DomainFields{
				Name:            "foo.com",
				RouterGroupType: "tcp",
			}

			expectedRoute = models.Route{
				Domain: expectedDomain,
				Host:   expectedHostname,
				Path:   expectedPath,
			}
		})

		Context("the route exists", func() {
			BeforeEach(func() {
				fakeRouteRepository.FindReturns(expectedRoute, nil)
			})

			It("does not create a route", func() {
				route, err := routeActor.FindOrCreateRoute(expectedHostname, expectedDomain, expectedPath, 0, false)
				Expect(route).To(Equal(expectedRoute))
				Expect(err).ToNot(HaveOccurred())

				Expect(fakeRouteRepository.CreateCallCount()).To(Equal(0))

				Expect(fakeUI.SayCallCount()).To(Equal(1))
				output, _ := fakeUI.SayArgsForCall(0)
				Expect(output).To(MatchRegexp("Using route.*hostname.foo.com/path"))
			})
		})
開發者ID:fujitsu-cf,項目名稱:cli,代碼行數:29,代碼來源:routes_test.go


注:本文中的code/cloudfoundry/org/cli/cf/api/apifakes.FakeRouteRepository.FindReturns方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。