) var _ = Describe("Sum", func() { var sum database.Aggregator BeforeEach(func() { sum = aggregators.NewSum() }) It("Sums all the account values", func() { accs := []*transaction.Account{ { Name: "some-name-1", Value: 1234, }, { Name: "some-name-2", Value: 5678, }, } Expect(sum.Aggregate(accs)).To(Equal("$69.12")) }) It("registers itself with the aggregator store", func() { Expect(aggregators.Store()).To(HaveKey("sum")) }) })
. "github.com/onsi/gomega" ) var _ = Describe("Count", func() { var count database.Aggregator BeforeEach(func() { count = aggregators.NewCount() }) It("Sums all the account values", func() { accs := []*transaction.Account{ { Name: "some-name-1", Value: 1234, }, { Name: "some-name-2", Value: 5678, }, } Expect(count.Aggregate(accs)).To(Equal("2")) }) It("registers itself with the aggregator store", func() { Expect(aggregators.Store()).To(HaveKey("count")) }) })
) var _ = Describe("Mean", func() { var mean database.Aggregator BeforeEach(func() { mean = aggregators.NewMean() }) It("returns the mean", func() { accs := []*transaction.Account{ { Name: "some-name-1", Value: 1000, }, { Name: "some-name-2", Value: 500, }, } Expect(mean.Aggregate(accs)).To(Equal("$7.50")) }) It("registers itself with the aggregator store", func() { Expect(aggregators.Store()).To(HaveKey("mean")) }) })