var _ = Describe("Spammer", func() { var ( kv *fakeKV spammer *helpers.Spammer prefix string ) Context("Check", func() { BeforeEach(func() { prefix = fmt.Sprintf("some-prefix-%v", rand.Int()) kv = newFakeKV() kv.AddressCall.Returns.Address = "http://some-address/consul" spammer = helpers.NewSpammer(kv, time.Duration(0), prefix) spammer.Spam() Eventually(func() int { return kv.SetCall.CallCount.Value() }).Should(BeNumerically(">", 1)) spammer.Stop() }) It("gets all the sets", func() { Expect(spammer.Check()).To(Succeed()) Expect(kv.GetCall.CallCount).Should(Equal(kv.SetCall.CallCount.Value())) }) It("returns an error when a key doesn't exist", func() { kv.GetCall.Returns.Error = fmt.Errorf("could not find key: %s-some-key-0", prefix)