예제 #1
0
package aggregators_test

import (
	"github.com/apoydence/ledger/aggregators"
	"github.com/apoydence/ledger/database"
	"github.com/apoydence/ledger/transaction"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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,
			},
		}
예제 #2
0
package aggregators_test

import (
	"github.com/apoydence/ledger/aggregators"
	"github.com/apoydence/ledger/database"
	"github.com/apoydence/ledger/transaction"

	. "github.com/onsi/ginkgo"
	. "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"))
예제 #3
0
package aggregators_test

import (
	"github.com/apoydence/ledger/aggregators"
	"github.com/apoydence/ledger/database"
	"github.com/apoydence/ledger/transaction"

	. "github.com/onsi/ginkgo"
	. "github.com/onsi/gomega"
)

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,
			},
		}