本文整理汇总了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
}
开发者ID:johannespetzold,项目名称:gorouter,代码行数:35,代码来源:main_test.go
示例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
}
开发者ID:tomzhang,项目名称:golang-devops-stuff,代码行数:27,代码来源:helper_test.go
示例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
}
}
开发者ID:johntdyer,项目名称:golang-devops-stuff,代码行数:30,代码来源:integration_test.go
示例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
}
开发者ID:idouba,项目名称:gorouter,代码行数:10,代码来源:helper_test.go
示例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
}
开发者ID:johnvilsack,项目名称:golang-stuff,代码行数:21,代码来源:integration_test.go
示例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
}
开发者ID:jackfengibm,项目名称:gorouter,代码行数:21,代码来源:router_test.go
示例7: appUnregistered
func appUnregistered(routesUri string, app *test.TestApp) bool {
routeFound, err := routeExists(routesUri, string(app.Urls()[0]))
return err == nil && !routeFound
}
开发者ID:jungle0755,项目名称:gorouter,代码行数:4,代码来源:main_test.go
示例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())
开发者ID:shashankmjain,项目名称:gorouter,代码行数:30,代码来源:router_test.go
注:本文中的github.com/cloudfoundry/gorouter/test.TestApp类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论