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


Golang test.TestApp類代碼示例

本文整理匯總了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;未經允許,請勿轉載。