Skip to content

Commit

Permalink
test: make race condition test part of the suite
Browse files Browse the repository at this point in the history
  • Loading branch information
zepatrik committed May 30, 2022
1 parent bdc55e6 commit ee31dce
Showing 1 changed file with 7 additions and 8 deletions.
15 changes: 7 additions & 8 deletions connection_instrumented_test.go
Expand Up @@ -3,12 +3,10 @@ package pop
import (
"context"
"fmt"
"github.com/stretchr/testify/require"
"golang.org/x/sync/errgroup"
"os"
"strings"
"sync"
"testing"
"time"

"github.com/luna-duclos/instrumentedsql"
Expand Down Expand Up @@ -77,6 +75,8 @@ func testInstrumentedDriver(p *suite.Suite) {
deets.UseInstrumentedDriver = true
deets.InstrumentedDriverOptions = []instrumentedsql.Opt{instrumentedsql.WithLogger(checker)}

testInstrumentationRace(p, &deets)

c, err := NewConnection(&deets)
r.NoError(err)
r.NoError(c.Open())
Expand All @@ -103,10 +103,12 @@ func (s *CockroachSuite) Test_Instrumentation() {
testInstrumentedDriver(&s.Suite)
}

func Test_InstrumentationRace(t *testing.T) {
r := require.New(t)
func testInstrumentationRace(p *suite.Suite, deets *ConnectionDetails) {
r := p.Require()
eg1, eg2 := errgroup.Group{}, errgroup.Group{}

r.True(deets.UseInstrumentedDriver)

tryInstrumentDriver := func(release chan struct{}) func() (err error) {
return func() (err error) {
defer func() {
Expand All @@ -116,10 +118,7 @@ func Test_InstrumentationRace(t *testing.T) {
}
}()
_, _, err = instrumentDriver(
&ConnectionDetails{
URL: "postgres://foo.bar",
UseInstrumentedDriver: true,
},
deets,
"postgres",
release,
)
Expand Down

0 comments on commit ee31dce

Please sign in to comment.