Skip to content

Commit

Permalink
Add ctx.Done on closing the test
Browse files Browse the repository at this point in the history
  • Loading branch information
aditya1702 committed Nov 18, 2024
1 parent ef16a2e commit c8ba420
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions internal/services/ingest_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -222,11 +222,15 @@ func TestIngestPayments(t *testing.T) {

func TestIngest_LatestSyncedLedgerBehindRPC(t *testing.T) {
dbt := dbtest.Open(t)
defer dbt.Close()

dbConnectionPool, err := db.OpenDBConnectionPool(dbt.DSN)
require.NoError(t, err)
defer dbConnectionPool.Close()

ctx := context.Background()
defer func() {
ctx.Done()
_ = dbConnectionPool.Close()
dbt.Close()
}()

models, _ := data.NewModels(dbConnectionPool)
mockAppTracker := apptracker.MockAppTracker{}
Expand Down Expand Up @@ -285,9 +289,8 @@ func TestIngest_LatestSyncedLedgerBehindRPC(t *testing.T) {
OldestLedgerCloseTime: int64(1),
}
mockRPCService.On("GetTransactions", int64(50), "", 50).Return(mockResult, nil).Once()
//mockAppTracker.On("CaptureMessage", "ingestion service stale for over 1m0s").Maybe()

err = ingestService.Run(context.Background(), uint32(49), uint32(50))
err = ingestService.Run(ctx, uint32(49), uint32(50))
require.NoError(t, err)

mockRPCService.AssertNotCalled(t, "GetTransactions", int64(49), "", int64(50))
Expand Down

0 comments on commit c8ba420

Please sign in to comment.