var expectedTTL time.Duration var expectedTTL2 time.Duration BeforeEach(func() { expectedTTL = 10 * time.Second 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)