本文整理匯總了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))