Skip to content

Commit 615fbec

Browse files
committed
[no-release-notes] testing/go/binding_test.go: Fix a race condition in our Listener GetRunningServer() usage beacuse these tests were not waiting for services stop before they finished.
Not waiting meant that the test running could go on and start another test while the previous server was still tearing down.
1 parent 5da9081 commit 615fbec

1 file changed

Lines changed: 10 additions & 2 deletions

File tree

testing/go/binding_test.go

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,11 @@ import (
2828
func TestBindingWithOidZero(t *testing.T) {
2929
// Start up a test server
3030
ctx, connection, controller := CreateServer(t, "postgres")
31-
defer controller.Stop()
31+
defer func() {
32+
connection.Close(ctx)
33+
controller.Stop()
34+
require.NoError(t, controller.WaitForStop())
35+
}()
3236
conn := connection.Default
3337

3438
// Create a table to insert into
@@ -51,7 +55,11 @@ func TestBindingWithOidZero(t *testing.T) {
5155

5256
func TestBindingWithTextArray(t *testing.T) {
5357
ctx, connection, controller := CreateServer(t, "postgres")
54-
defer controller.Stop()
58+
defer func() {
59+
connection.Close(ctx)
60+
controller.Stop()
61+
require.NoError(t, controller.WaitForStop())
62+
}()
5563
conn := connection.Default
5664

5765
m := pgtype.NewMap()

0 commit comments

Comments
 (0)