Skip to content

Commit

Permalink
fix: tests
Browse files Browse the repository at this point in the history
Signed-off-by: Lawrence Zawila <113581282+darkmatterpool@users.noreply.github.com>
  • Loading branch information
darkmatterpool committed Oct 26, 2022
1 parent 0a6ee3a commit 42e78a1
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 4 deletions.
3 changes: 3 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,6 @@ lint:
lint-fix:
golangci-lint run --fix

run-tests:
go test -race -count=1 ./...

6 changes: 2 additions & 4 deletions internal/pkg/ingestion/ingester.go
Original file line number Diff line number Diff line change
Expand Up @@ -74,13 +74,13 @@ func (i *DefaultIngester) processBatch(ctx context.Context, batch Batch) ([]paym
Referenced: elem.Referenced,
Provider: i.provider,
})
if ret.Err() != nil && errors.Is(ret.Err(), mongo.ErrNoDocuments) {
if ret.Err() != nil && !errors.Is(ret.Err(), mongo.ErrNoDocuments) {
logger.Errorf("Error retrieving payment: %s", ret.Err())

return nil, fmt.Errorf("error retrieving payment: %w", ret.Err())
}

if ret.Err() == nil {
if ret != nil && ret.Err() == nil {
payment := payments.Payment{}

err := ret.Decode(&payment)
Expand All @@ -94,8 +94,6 @@ func (i *DefaultIngester) processBatch(ctx context.Context, batch Batch) ([]paym
}
}

var err error

switch {
case elem.Forward && elem.Adjustment != nil:
update = bson.M{
Expand Down
9 changes: 9 additions & 0 deletions internal/pkg/ingestion/ingester_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,14 @@ func TestIngester(t *testing.T) {
ingester := NewDefaultIngester(provider, uuid.New(), mt.DB, sharedlogging.NewNoOpLogger(), nil)

mt.AddMockResponses(
mtest.CreateCursorResponse(1, "test.test", mtest.FirstBatch, bson.D{
{Key: "ok", Value: 1},
{Key: "value", Value: bson.D{}},
}),
bson.D{
{Key: "ok", Value: 1},
{Key: "value", Value: bson.D{}},
}, // Find payment update
bson.D{
{Key: "ok", Value: 1},
{Key: "value", Value: bson.D{}},
Expand All @@ -51,6 +59,7 @@ func TestIngester(t *testing.T) {
}, State{
Counter: 1,
})

require.NoError(t, err)
})
}

0 comments on commit 42e78a1

Please sign in to comment.