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