Skip to content

Commit 1ce4587

Browse files
committed
fix data race in tests
1 parent 42fa898 commit 1ce4587

File tree

1 file changed

+5
-0
lines changed

1 file changed

+5
-0
lines changed

internal/consuming/postgresql_test.go

+5
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import (
66
"context"
77
"fmt"
88
"strings"
9+
"sync"
910
"testing"
1011
"time"
1112

@@ -313,8 +314,12 @@ func TestPostgresConsumer_DifferentPartitions(t *testing.T) {
313314

314315
numEvents := 0
315316

317+
var dispatchMu sync.Mutex
318+
316319
consumer, err := NewPostgresConsumer("test", &MockLogger{}, &MockDispatcher{
317320
onDispatch: func(ctx context.Context, method string, data []byte) error {
321+
dispatchMu.Lock()
322+
defer dispatchMu.Unlock()
318323
require.Equal(t, testMethod, method)
319324
require.Equal(t, testPayload, data)
320325
numEvents++

0 commit comments

Comments
 (0)