本文整理汇总了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() {