@@ -10,15 +10,17 @@ import (
1010 "reflect"
1111 "strconv"
1212 "strings"
13+ "sync/atomic"
1314 "testing"
1415 "time"
1516
16- "github.com/go-mysql-org/go-mysql/client"
17- "github.com/go-mysql-org/go-mysql/mysql"
18- "github.com/go-mysql-org/go-mysql/server"
1917 "github.com/pingcap/errors"
2018 "github.com/siddontang/go/log"
2119 "github.com/stretchr/testify/require"
20+
21+ "github.com/go-mysql-org/go-mysql/client"
22+ "github.com/go-mysql-org/go-mysql/mysql"
23+ "github.com/go-mysql-org/go-mysql/server"
2224)
2325
2426var _ server.Handler = & mockHandler {}
@@ -32,7 +34,7 @@ type testServer struct {
3234
3335type mockHandler struct {
3436 // the number of times a query executed
35- queryCount int
37+ queryCount atomic. Int32
3638}
3739
3840func TestDriverOptions_SetRetriesOn (t * testing.T ) {
@@ -54,7 +56,7 @@ func TestDriverOptions_SetRetriesOn(t *testing.T) {
5456
5557 // here we issue assert that even though we only issued 1 query, that the retries
5658 // remained on and there were 3 calls to the DB.
57- require .Equal (t , 3 , srv .handler .queryCount )
59+ require .EqualValues (t , 3 , srv .handler .queryCount . Load () )
5860}
5961
6062func TestDriverOptions_SetRetriesOff (t * testing.T ) {
@@ -75,7 +77,7 @@ func TestDriverOptions_SetRetriesOff(t *testing.T) {
7577
7678 // here we issue assert that even though we only issued 1 query, that the retries
7779 // remained on and there were 3 calls to the DB.
78- require .Equal (t , 1 , srv .handler .queryCount )
80+ require .EqualValues (t , 1 , srv .handler .queryCount . Load () )
7981}
8082
8183func TestDriverOptions_SetCollation (t * testing.T ) {
@@ -309,7 +311,7 @@ func (h *mockHandler) UseDB(dbName string) error {
309311}
310312
311313func (h * mockHandler ) handleQuery (query string , binary bool , args []interface {}) (* mysql.Result , error ) {
312- h .queryCount ++
314+ h .queryCount . Add ( 1 )
313315 ss := strings .Split (query , " " )
314316 switch strings .ToLower (ss [0 ]) {
315317 case "select" :
0 commit comments