本文整理汇总了Golang中github.com/cloudfoundry/cli/cf/api/apifakes.FakeRouteRepository.FindReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeRouteRepository.FindReturns方法的具体用法?Golang FakeRouteRepository.FindReturns怎么用?Golang FakeRouteRepository.FindReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/cloudfoundry/cli/cf/api/apifakes.FakeRouteRepository
的用法示例。
在下文中一共展示了FakeRouteRepository.FindReturns方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
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"}
})
示例2:
expectedPath = "path"
expectedDomain = models.DomainFields{
Name: "foo.com",
}
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, 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"))
})
})
示例3:
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"},
示例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:
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() {
示例6:
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"))
})
})