本文整理匯總了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"))
示例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))
示例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)))
})
示例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 = ""
}
示例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() {