Exemple #1
0
				db.Route{},
			}, nil)
		})

		JustBeforeEach(func() {
			go reporter.Run(sigChan, readyChan)
		})

		AfterEach(func() {
			sigChan <- nil
		})

		It("emits total_subscriptions on start", func() {
			Eventually(stats.GaugeCallCount).Should(Equal(1))

			totalStat, count, rate := stats.GaugeArgsForCall(0)
			Expect(totalStat).To(Equal("total_subscriptions"))
			Expect(count).To(BeNumerically("==", 0))
			Expect(rate).To(BeNumerically("==", 1.0))
		})

		It("periodically sends a delta of 0 to total_subscriptions", func() {
			tickChan <- time.Now()

			Eventually(stats.GaugeDeltaCallCount).Should(Equal(1))

			totalStat, count, rate := stats.GaugeDeltaArgsForCall(0)
			Expect(totalStat).To(Equal("total_subscriptions"))
			Expect(count).To(BeNumerically("==", 0))
			Expect(rate).To(BeNumerically("==", 1.0))
		})
				db.TcpRouteMapping{},
				db.TcpRouteMapping{},
				db.TcpRouteMapping{},
			}, nil)
		})

		JustBeforeEach(func() {
			go reporter.Run(sigChan, readyChan)
		})

		AfterEach(func() {
			sigChan <- nil
		})

		verifyGaugeCall := func(statKey string, expectedCount int64, expectedRate float32, index int) {
			totalStat, count, rate := stats.GaugeArgsForCall(index)
			Expect(totalStat).To(Equal(statKey))
			Expect(count).To(BeNumerically("==", expectedCount))
			Expect(rate).To(BeNumerically("==", expectedRate))
		}

		verifyGaugeDeltaCall := func(statKey string, expectedCount int64, expectedRate float32, index int) {
			totalStat, count, rate := stats.GaugeDeltaArgsForCall(index)
			Expect(totalStat).To(Equal(statKey))
			Expect(count).To(BeNumerically("==", expectedCount))
			Expect(rate).To(BeNumerically("==", expectedRate))
		}

		It("emits total_subscriptions on start", func() {
			Eventually(stats.GaugeCallCount).Should(Equal(2))
			verifyGaugeCall("total_subscriptions", 0, 1.0, 0)