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


Golang FakeClock.Increment方法代碼示例

本文整理匯總了Golang中code/cloudfoundry/org/clock/fakeclock.FakeClock.Increment方法的典型用法代碼示例。如果您正苦於以下問題:Golang FakeClock.Increment方法的具體用法?Golang FakeClock.Increment怎麽用?Golang FakeClock.Increment使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在code/cloudfoundry/org/clock/fakeclock.FakeClock的用法示例。


在下文中一共展示了FakeClock.Increment方法的5個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Golang代碼示例。

示例1:

		AfterEach(func() {
			process.Signal(os.Interrupt)
			Eventually(process.Wait(), 5*time.Second).Should(Receive())
		})

		It("subscribes for events", func() {
			Eventually(client.SubscribeToEventsWithMaxRetriesCallCount).Should(Equal(1))
		})

		Context("on specified interval", func() {
			BeforeEach(func() {
				client.SubscribeToEventsWithMaxRetriesReturns(&fake_routing_api.FakeEventSource{}, errors.New("not used"))
			})

			It("fetches routes", func() {
				clock.Increment(cfg.PruneStaleDropletsInterval + 100*time.Millisecond)
				Eventually(client.RoutesCallCount, 2*time.Second, 50*time.Millisecond).Should(Equal(1))
				clock.Increment(cfg.PruneStaleDropletsInterval + 100*time.Millisecond)
				Eventually(client.RoutesCallCount, 2*time.Second, 50*time.Millisecond).Should(Equal(2))
			})

			It("uses cache when fetching token from uaa", func() {
				clock.Increment(cfg.PruneStaleDropletsInterval + 100*time.Millisecond)
				Eventually(client.RoutesCallCount, 2*time.Second, 50*time.Millisecond).Should(Equal(1))
				Expect(uaaClient.FetchTokenArgsForCall(0)).To(Equal(false))
			})
		})

		Context("when token fetcher returns error", func() {
			BeforeEach(func() {
				uaaClient.FetchTokenReturns(nil, errors.New("Unauthorized"))
開發者ID:cloudfoundry,項目名稱:gorouter,代碼行數:31,代碼來源:route_fetcher_test.go

示例2:

			It("should have fake driver in registry map", func() {
				drivers := registry.Drivers()
				Expect(len(drivers)).To(Equal(1))
				Expect(fakeDriverFactory.DriverCallCount()).To(Equal(1))
				Expect(fakeDriver.ActivateCallCount()).To(Equal(1))
			})

			Context("when drivers are added", func() {
				BeforeEach(func() {
					err := voldriver.WriteDriverSpec(logger, defaultPluginsDirectory, "anotherfakedriver", "spec", []byte("http://0.0.0.0:8080"))
					Expect(err).NotTo(HaveOccurred())
				})

				It("should find them!", func() {
					fakeClock.Increment(scanInterval * 2)
					Eventually(registry.Drivers).Should(HaveLen(2))
					Expect(fakeDriverFactory.DriverCallCount()).To(Equal(3))
					Expect(fakeDriver.ActivateCallCount()).To(Equal(3))
				})
			})
			Context("when drivers are not responding", func() {
				BeforeEach(func() {
					fakeDriver.ActivateReturns(voldriver.ActivateResponse{
						Err: "some err",
					})
				})

				It("should find no drivers", func() {
					fakeClock.Increment(scanInterval * 2)
					Eventually(registry.Drivers).Should(HaveLen(0))
開發者ID:cloudfoundry-incubator,項目名稱:volman,代碼行數:30,代碼來源:driver_syncer_test.go

示例3:

		}).Should(Equal(numSessions))
	}

	Context("When consul is running", func() {
		Context("an error occurs while acquiring the lock", func() {
			BeforeEach(func() {
				lockKey = ""
			})

			It("continues to retry", func() {
				lockProcess = ifrit.Background(lockRunner)
				shouldEventuallyHaveNumSessions(1)
				Consistently(lockProcess.Ready()).ShouldNot(BeClosed())
				Consistently(lockProcess.Wait()).ShouldNot(Receive())

				clock.Increment(retryInterval)
				Eventually(logger).Should(Say("acquire-lock-failed"))
				Eventually(logger).Should(Say("retrying-acquiring-lock"))
				Expect(sender.GetValue(lockHeldMetricName).Value).To(Equal(float64(0)))
			})
		})

		Context("and the lock is available", func() {
			It("acquires the lock", func() {
				lockProcess = ifrit.Background(lockRunner)
				Eventually(lockProcess.Ready()).Should(BeClosed())
				Expect(sender.GetValue(lockUptimeMetricName).Value).Should(Equal(float64(0)))
				Expect(getLockValue()).To(Equal(lockValue))
				Expect(sender.GetValue(lockHeldMetricName).Value).To(Equal(float64(1)))
			})
開發者ID:cloudfoundry,項目名稱:locket,代碼行數:30,代碼來源:lock_test.go

示例4:

}

var verifyFetchWithRetries = func(client uaa_go_client.Client, server *ghttp.Server, numRetries int, expectedErrorMsg string) {
	var err error
	wg := sync.WaitGroup{}
	wg.Add(1)
	go func(wg *sync.WaitGroup) {
		defer GinkgoRecover()
		defer wg.Done()
		_, err = client.FetchToken(forceUpdate)
		Expect(err).To(HaveOccurred())
	}(&wg)

	for i := 0; i < numRetries; i++ {
		Eventually(server.ReceivedRequests, 7*time.Second, 1*time.Second).Should(HaveLen(i + 1))
		clock.Increment(DefaultRetryInterval + 10*time.Second)
	}

	wg.Wait()

	Expect(err.Error()).To(ContainSubstring(expectedErrorMsg))
}

var getRegisterOauthClientHandlerFunc = func(status int, token *schema.Token, oauthClient *schema.OauthClient) http.HandlerFunc {
	oauthClientString, err := json.Marshal(oauthClient)
	var responseBody string
	if status == http.StatusOK {
		responseBody = string(oauthClientString)
	} else {
		responseBody = ""
	}
開發者ID:cloudfoundry-incubator,項目名稱:uaa-go-client,代碼行數:31,代碼來源:client_suite_test.go

示例5:

		BeforeEach(func() {
			schedDone = make(chan struct{})
		})

		JustBeforeEach(func() {
			go func(sched *scheduler.Scheduler, c chan struct{}) {
				defer GinkgoRecover()
				Expect(sched.Run).NotTo(Panic())
				close(c)
			}(sched, schedDone)
			clk.WaitForWatcherAndIncrement(csSleep)
		})

		AfterEach(func() {
			Expect(sched.Stop()).To(Succeed())
			clk.Increment(csSleep)
			Eventually(schedDone).Should(BeClosed())
		})

		Context("when there are no tasks", func() {
			It("should not call the task selector", func() {
				Expect(taskSelector.SelectTaskCallCount()).To(Equal(0))
			})
		})

		Context("when there are tasks", func() {
			var (
				taskA, taskB *fakes.FakeTask
			)

			BeforeEach(func() {
開發者ID:glestaris,項目名稱:clique,代碼行數:31,代碼來源:scheduler_test.go


注:本文中的code/cloudfoundry/org/clock/fakeclock.FakeClock.Increment方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。