Skip to content

Commit

Permalink
Increased record subscriber code coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
pdt256 committed Jan 21, 2021
1 parent e0c916b commit 75fe361
Show file tree
Hide file tree
Showing 3 changed files with 37 additions and 3 deletions.
2 changes: 1 addition & 1 deletion .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ env:

script:
- go test -v -race -coverprofile c.out.tmp ./...
- cat c.out.tmp | grep -v "_vfsdata.go" | grep -v "_gen.go" | grep -v ".pb.go" | grep -v "/rangedbtest/" > c.out
- cat c.out.tmp | grep -v "_vfsdata.go" | grep -v "_gen.go" | grep -v ".pb.go" | grep -v "/rangedbtest/" | grep -v "/cryptotest/" > c.out
- go tool cover -func c.out

after_script:
Expand Down
4 changes: 2 additions & 2 deletions pkg/recordsubscriber/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ func AllEventsConfig(ctx context.Context, store rangedb.Store, broadcaster broad
}

// AggregateTypesConfig returns a configuration to subscribe to events by aggregate types.
func AggregateTypesConfig(ctx context.Context, store rangedb.Store, broadcaster broadcast.Broadcaster, bufLen int, aggregateTypes []string, consumeRecord ConsumeRecordFunc) Config {
func AggregateTypesConfig(ctx context.Context, store rangedb.Store, broadcaster broadcast.Broadcaster, bufferLength int, aggregateTypes []string, consumeRecord ConsumeRecordFunc) Config {
return Config{
BufferSize: bufLen,
BufferSize: bufferLength,
DoneChan: ctx.Done(),
Subscribe: func(subscriber broadcast.RecordSubscriber) {
broadcaster.SubscribeAggregateTypes(subscriber, aggregateTypes...)
Expand Down
34 changes: 34 additions & 0 deletions pkg/recordsubscriber/config_test.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
package recordsubscriber_test

import (
"context"
"testing"
"time"

"github.com/stretchr/testify/assert"

"github.com/inklabs/rangedb"
"github.com/inklabs/rangedb/pkg/broadcast"
"github.com/inklabs/rangedb/pkg/recordsubscriber"
"github.com/inklabs/rangedb/provider/inmemorystore"
)

func TestConfig(t *testing.T) {
// Given
ctx := context.Background()
store := inmemorystore.New()
broadcaster := broadcast.New(1, time.Nanosecond)
bufferLength := 1
consumeRecord := func(record *rangedb.Record) error {
return nil
}
var aggregateTypes []string

// When
allEventsConfig := recordsubscriber.AllEventsConfig(ctx, store, broadcaster, bufferLength, consumeRecord)
aggregateTypesConfig := recordsubscriber.AggregateTypesConfig(ctx, store, broadcaster, bufferLength, aggregateTypes, consumeRecord)

// Then
assert.IsType(t, recordsubscriber.Config{}, allEventsConfig)
assert.IsType(t, recordsubscriber.Config{}, aggregateTypesConfig)
}

0 comments on commit 75fe361

Please sign in to comment.