本文整理汇总了Golang中github.com/concourse/baggageclaim/fakes.FakeVolume.ExpirationReturns方法的典型用法代码示例。如果您正苦于以下问题:Golang FakeVolume.ExpirationReturns方法的具体用法?Golang FakeVolume.ExpirationReturns怎么用?Golang FakeVolume.ExpirationReturns使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类github.com/concourse/baggageclaim/fakes.FakeVolume
的用法示例。
在下文中一共展示了FakeVolume.ExpirationReturns方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1:
fakeBaggageclaimClient = new(bfakes.FakeClient)
satisfyingWorker.VolumeManagerReturns(fakeBaggageclaimClient, true)
})
Context("when the cache is already present", func() {
var foundVolume *bfakes.FakeVolume
BeforeEach(func() {
foundVolume = new(bfakes.FakeVolume)
foundVolume.HandleReturns("found-volume-handle")
cacheIdentifier.FindOnReturns(foundVolume, true, nil)
cacheIdentifier.ResourceVersionReturns(atc.Version{"some": "theversion"})
cacheIdentifier.ResourceHashReturns("hash")
satisfyingWorker.NameReturns("myworker")
foundVolume.ExpirationReturns(time.Hour, time.Now(), nil)
})
It("does not error and returns a resource", func() {
Expect(initErr).NotTo(HaveOccurred())
Expect(initResource).NotTo(BeNil())
})
It("chose the worker satisfying the resource type and tags", func() {
Expect(workerClient.SatisfyingArgsForCall(0)).To(Equal(worker.WorkerSpec{
ResourceType: "type1",
Tags: []string{"resource", "tags"},
}))
})
It("located it on the correct worker", func() {
示例2:
By("releasing the volume with a final ttl")
vol.Release(worker.FinalTTL(2 * time.Second))
Eventually(fakeVolume.SetTTLCallCount).Should(Equal(4))
actualTTL = fakeVolume.SetTTLArgsForCall(3)
Expect(actualTTL).To(Equal(2 * time.Second))
Eventually(fakeDB.SetVolumeTTLCallCount).Should(Equal(4))
actualHandle, actualTTL = fakeDB.SetVolumeTTLArgsForCall(3)
Expect(actualHandle).To(Equal(vol.Handle()))
Expect(actualTTL).To(Equal(2 * time.Second))
})
It("is resiliant to errors while heartbeating", func() {
By("using the baggage claim volumes ttl if the initial db lookup fails")
fakeVolume.ExpirationReturns(expectedTTL, time.Now(), nil)
fakeDB.GetVolumeTTLReturns(0, errors.New("disaster"))
_, err := volumeFactory.Build(logger, fakeVolume)
Expect(err).ToNot(HaveOccurred())
By("using that ttl to heartbeat the volume initially")
Expect(fakeVolume.SetTTLCallCount()).To(Equal(1))
actualTTL := fakeVolume.SetTTLArgsForCall(0)
Expect(actualTTL).To(Equal(expectedTTL))
By("continuing to use the same ttl if the db continues to error")
fakeClock.Increment(30 * time.Second)
Eventually(fakeVolume.SetTTLCallCount).Should(Equal(2))
actualTTL = fakeVolume.SetTTLArgsForCall(1)
Expect(actualTTL).To(Equal(expectedTTL))
})