Ejemplo n.º 1
0
			Expect(ok).To(BeTrue())
			Expect(value).To(Equal(1000000))

			Expect(values.SetInt(".parent.child", 12345)).To(Succeed())

			value, ok = values.Int(".parent.child")
			Expect(ok).To(BeTrue())
			Expect(value).To(Equal(12345))
		})
	})

	Describe("SetDuration()", func() {
		It("sets a duration value as a string", func() {
			values = jsonstruct.New()

			Expect(values.SetDuration(".duration-path", 32*time.Second)).To(Succeed())

			Expect(values["duration-path"]).To(Equal("32s"))
		})
	})

	Describe("SetList()", func() {
		It("sets a list", func() {
			values = jsonstruct.New()

			sub := jsonstruct.New()
			sub.SetString(".x", "y")
			list := []interface{}{1, "u", sub}

			Expect(values.SetList(".doc.list", list)).To(Succeed())
Ejemplo n.º 2
0
		MessageCount: 0,
		ByteCount:    0,
		ErrorCount:   0,
	}
	singleMessageReport := streaming.Report{
		MessageCount: 1,
		ByteCount:    1024,
		ErrorCount:   0,
	}

	Context("with a 5-messages-per-second configuration", func() {
		BeforeEach(func() {
			// one message per 100ms
			config.SetInt(streaming.MessagesPerSecond, 10)
			// will alternate reports of 0 and 1 messages per report
			config.SetDuration(streaming.ReportCycle, 80*time.Millisecond)

			err := scheme.Init(config)
			Expect(err).NotTo(HaveOccurred())
		})

		It("sets up the reporter properly", func() {
			Expect(reporter.expectedMessagesPerSecond).To(Equal(10))
			Expect(reporter.reportCycle).To(Equal(80 * time.Millisecond))
		})

		It("writes messages at the rate specified", func() {
			go scheme.RunWriter(writer)

			Eventually(reporter.reports, 100*time.Millisecond).Should(Receive(Equal(emptyReport)))
			Eventually(reporter.reports, 100*time.Millisecond).Should(Receive(Equal(singleMessageReport)))