本文整理匯總了Golang中github.com/cloudfoundry/gorouter/test.TestApp類的典型用法代碼示例。如果您正苦於以下問題:Golang TestApp類的具體用法?Golang TestApp怎麽用?Golang TestApp使用的例子?那麽, 這裏精選的類代碼示例或許可以為您提供幫助。
在下文中一共展示了TestApp類的8個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。
示例1: waitMsgReceived
func waitMsgReceived(uri string, app *test.TestApp, expectedToBeFound bool, timeout time.Duration) bool {
interval := time.Millisecond * 50
repetitions := int(timeout / interval)
for j := 0; j < repetitions; j++ {
resp, err := http.Get(uri)
if err == nil {
switch resp.StatusCode {
case http.StatusOK:
bytes, err := ioutil.ReadAll(resp.Body)
resp.Body.Close()
Ω(err).ShouldNot(HaveOccurred())
routes := make(map[string][]string)
err = json.Unmarshal(bytes, &routes)
Ω(err).ShouldNot(HaveOccurred())
route := routes[string(app.Urls()[0])]
if expectedToBeFound {
if route != nil {
return true
}
} else {
if route == nil {
return true
}
}
default:
println("Failed to receive routes: ", resp.StatusCode, uri)
}
}
time.Sleep(interval)
}
return false
}
示例2: waitMsgReceived
func waitMsgReceived(registry *registry.RouteRegistry, app *test.TestApp, expectedToBeFound bool, timeout time.Duration) bool {
interval := time.Millisecond * 50
repetitions := int(timeout / interval)
for j := 0; j < repetitions; j++ {
if j > 0 {
time.Sleep(interval)
}
received := true
for _, url := range app.Urls() {
pool := registry.Lookup(url)
if expectedToBeFound && pool == nil {
received = false
break
} else if !expectedToBeFound && pool != nil {
received = false
break
}
}
if received {
return true
}
}
return false
}
示例3: waitMsgReceived
func (s *IntegrationSuite) waitMsgReceived(a *test.TestApp, shouldBeRegistered bool, t time.Duration) bool {
registeredOrUnregistered := make(chan bool)
go func() {
for {
received := true
for _, v := range a.Urls() {
_, ok := s.router.registry.Lookup(v)
if ok != shouldBeRegistered {
received = false
break
}
}
if received {
registeredOrUnregistered <- true
break
}
time.Sleep(50 * time.Millisecond)
}
}()
select {
case <-registeredOrUnregistered:
return true
case <-time.After(t):
return false
}
}
示例4: appUnregistered
func appUnregistered(registry *registry.RouteRegistry, app *test.TestApp) bool {
for _, url := range app.Urls() {
pool := registry.Lookup(url)
if pool != nil {
return false
}
}
return true
}
示例5: waitMsgReceived
func (s *IntegrationSuite) waitMsgReceived(a *test.TestApp, r bool, t time.Duration) bool {
i := time.Millisecond * 50
m := int(t / i)
for j := 0; j < m; j++ {
received := true
for _, v := range a.Urls() {
_, ok := s.router.registry.Lookup(v)
if ok != r {
received = false
break
}
}
if received {
return true
}
time.Sleep(i)
}
return false
}
示例6: waitMsgReceived
func (s *RouterSuite) waitMsgReceived(app *test.TestApp, expectedToBeFound bool, timeout time.Duration) bool {
interval := time.Millisecond * 50
repetitions := int(timeout / interval)
for j := 0; j < repetitions; j++ {
received := true
for _, url := range app.Urls() {
_, ok := s.router.registry.Lookup(url)
if ok != expectedToBeFound {
received = false
break
}
}
if received {
return true
}
time.Sleep(interval)
}
return false
}
示例7: appUnregistered
func appUnregistered(routesUri string, app *test.TestApp) bool {
routeFound, err := routeExists(routesUri, string(app.Urls()[0]))
return err == nil && !routeFound
}
示例8:
var emptyTime time.Time
var emptyDuration vcap.Duration
Expect(varz.Type).To(Equal("Router"))
Expect(varz.Index).To(Equal(uint(2)))
Expect(varz.UUID).ToNot(Equal(""))
Expect(varz.StartTime).ToNot(Equal(emptyTime))
Expect(varz.Uptime).ToNot(Equal(emptyDuration))
verify_var_z(varz.Host, varz.Credentials[0], varz.Credentials[1])
verify_health_z(varz.Host, registry)
})
Context("Register and Unregister", func() {
var app *test.TestApp
assertRegisterUnregister := func() {
app.Listen()
Eventually(func() bool {
return appRegistered(registry, app)
}).Should(BeTrue())
app.VerifyAppStatus(200)
app.Unregister()
Eventually(func() bool {
return appUnregistered(registry, app)
}).Should(BeTrue())