本文整理汇总了Golang中github.com/concourse/baggageclaim/fakes.FakeVolume.SetTTLCallCount方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeVolume.SetTTLCallCount方法的具体用法?Golang FakeVolume.SetTTLCallCount怎么用?Golang FakeVolume.SetTTLCallCount使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/baggageclaim/fakes.FakeVolume
的用法示例。
在下文中一共展示了FakeVolume.SetTTLCallCount方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
aVolume = new(bfakes.FakeVolume)
aVolume.HandleReturns("a")
bVolume = new(bfakes.FakeVolume)
bVolume.HandleReturns("b")
})
Context("with a, b order", func() {
BeforeEach(func() {
fakeBaggageclaimClient.ListVolumesReturns([]baggageclaim.Volume{aVolume, bVolume}, nil)
})
It("selects the volume based on the lowest alphabetical name", func() {
Expect(foundVolume).To(Equal(aVolume))
Expect(found).To(BeTrue())
Expect(aVolume.SetTTLCallCount()).To(Equal(0))
Expect(bVolume.ReleaseCallCount()).To(Equal(1))
Expect(bVolume.ReleaseArgsForCall(0)).To(Equal(worker.FinalTTL(time.Minute)))
})
})
Context("with b, a order", func() {
BeforeEach(func() {
fakeBaggageclaimClient.ListVolumesReturns([]baggageclaim.Volume{bVolume, aVolume}, nil)
})
It("selects the volume based on the lowest alphabetical name", func() {
Expect(foundVolume).To(Equal(aVolume))
Expect(found).To(BeTrue())
Expect(aVolume.SetTTLCallCount()).To(Equal(0))
示例2:
expectedTTL2 = 5 * time.Second
fakeVolume.HandleReturns("some-handle")
fakeDB.GetVolumeTTLReturns(expectedTTL, nil)
})
It("heartbeats", func() {
vol, err := volumeFactory.Build(logger, fakeVolume)
Expect(err).ToNot(HaveOccurred())
By("looking up the initial ttl in the database")
Expect(fakeDB.GetVolumeTTLCallCount()).To(Equal(1))
actualHandle := fakeDB.GetVolumeTTLArgsForCall(0)
Expect(actualHandle).To(Equal("some-handle"))
By("using that ttl to heartbeat the volume initially")
Expect(fakeVolume.SetTTLCallCount()).To(Equal(1))
actualTTL := fakeVolume.SetTTLArgsForCall(0)
Expect(actualTTL).To(Equal(expectedTTL))
Expect(fakeDB.SetVolumeTTLCallCount()).To(Equal(1))
actualHandle, actualTTL = fakeDB.SetVolumeTTLArgsForCall(0)
Expect(actualHandle).To(Equal(vol.Handle()))
Expect(actualTTL).To(Equal(expectedTTL))
By("using the ttl from the database each tick")
fakeDB.GetVolumeTTLReturns(expectedTTL2, nil)
fakeClock.Increment(30 * time.Second)
Eventually(fakeVolume.SetTTLCallCount).Should(Equal(2))
actualTTL = fakeVolume.SetTTLArgsForCall(1)
Expect(actualTTL).To(Equal(expectedTTL2))