本文整理匯總了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() {
示例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"},
示例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"}
})
示例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"))
})
})
示例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"))
})
})