Expect(fakeMetricSender.GetCounter("count1")).To(BeEquivalentTo(0)) // should not increment. Expect(fakeMetricSender.GetCounter("count2")).To(BeEquivalentTo(0)) // should not increment. time.Sleep(75 * time.Millisecond) Expect(fakeMetricSender.GetCounter("count1")).To(BeEquivalentTo(2)) // should update counter only when time out Expect(fakeMetricSender.GetCounter("count2")).To(BeEquivalentTo(3)) // should update counter only when time out metricBatcher.BatchAddCounter("count1", 2) metricBatcher.BatchAddCounter("count2", 2) Expect(fakeMetricSender.GetCounter("count1")).To(BeEquivalentTo(2)) // should update counter only when time out Expect(fakeMetricSender.GetCounter("count2")).To(BeEquivalentTo(3)) // should update counter only when time out time.Sleep(75 * time.Millisecond) Expect(fakeMetricSender.GetCounter("count1")).To(BeEquivalentTo(4)) // should update counter only when time out Expect(fakeMetricSender.GetCounter("count2")).To(BeEquivalentTo(5)) // should update counter only when time out }) }) Describe("Reset", func() { It("cancels any scheduled counter emission", func() { metricBatcher.BatchAddCounter("count1", 2) metricBatcher.BatchIncrementCounter("count1") metricBatcher.Reset() Consistently(func() uint64 { return fakeMetricSender.GetCounter("count1") }).Should(BeZero()) }) }) })