Skip to content

Commit 272fe81

Browse files
committed
fix issues in tests TestNoArgsCommand (+ rename it to TestSimpleCommandOK) and TestReset: fix messages and comments, close DB connections
1 parent 3d484fc commit 272fe81

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

driver_test.go

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2329,14 +2329,14 @@ func TestPing(t *testing.T) {
23292329
})
23302330
}
23312331

2332-
func TestNoArgsCommand(t *testing.T) {
2332+
func TestSimpleCommandOK(t *testing.T) {
23332333
ctx := context.Background()
23342334
for _, test := range []struct{
23352335
method string
23362336
query string
23372337
funcToCall func(ctx context.Context, mc *mysqlConn) error
23382338
} {
2339-
{method: "Ping", query: "Ping", funcToCall: func(ctx context.Context, mc *mysqlConn) error {return mc.Ping(ctx)}},
2339+
{method: "Pinger", query: "Ping", funcToCall: func(ctx context.Context, mc *mysqlConn) error {return mc.Ping(ctx)}},
23402340
{method: "Conn", query: "Reset", funcToCall: func(ctx context.Context, mc *mysqlConn) error {return mc.Reset(ctx)}},
23412341
} {
23422342
test := test
@@ -2346,6 +2346,7 @@ func TestNoArgsCommand(t *testing.T) {
23462346
if err != nil {
23472347
dbt.fail("db", "Conn", err)
23482348
}
2349+
defer conn.Close()
23492350

23502351
// Check that affectedRows and insertIds are cleared after each call.
23512352
conn.Raw(func(conn any) error {
@@ -2373,7 +2374,7 @@ func TestNoArgsCommand(t *testing.T) {
23732374
t.Errorf("bad affectedRows: got %v, want=%v", got, want)
23742375
}
23752376
if got, want := c.result.insertIds, []int64(nil); !reflect.DeepEqual(got, want) {
2376-
t.Errorf("bad affectedRows: got %v, want=%v", got, want)
2377+
t.Errorf("bad insertIds: got %v, want=%v", got, want)
23772378
}
23782379
}
23792380
return nil
@@ -2390,8 +2391,9 @@ func TestReset(t *testing.T) {
23902391
if err != nil {
23912392
dbt.fail("db", "Conn", err)
23922393
}
2394+
defer conn.Close()
23932395

2394-
// Check that affectedRows and insertIds are cleared after each call.
2396+
// Verify that COM_RESET_CONNECTION clears session state (e.g., user variables).
23952397
conn.Raw(func(conn any) error {
23962398
c := conn.(*mysqlConn)
23972399

0 commit comments

Comments
 (0)