Skip to content

Commit 9c308f1

Browse files
committed
allow skipping TestReset and TestSimpleCommandOK_Reset when COM_RESET_CONNECTION is not supported by the DB, support the text protocol when using driver.Rows() in TestReset()
1 parent 272fe81 commit 9c308f1

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

driver_test.go

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2368,6 +2368,11 @@ func TestSimpleCommandOK(t *testing.T) {
23682368
// Verify that Ping()/Reset() clears both fields.
23692369
for range 2 {
23702370
if err := test.funcToCall(ctx, c); err != nil {
2371+
// Skip Reset on servers lacking COM_RESET_CONNECTION support.
2372+
if test.query == "Reset" {
2373+
maybeSkip(t, err, 1047) // ER_UNKNOWN_COM_ERROR
2374+
maybeSkip(t, err, 1235) // ER_NOT_SUPPORTED_YET
2375+
}
23712376
dbt.fail(test.method, test.query, err)
23722377
}
23732378
if got, want := c.result.affectedRows, []int64(nil); !reflect.DeepEqual(got, want) {
@@ -2406,7 +2411,7 @@ func TestReset(t *testing.T) {
24062411
if err != nil {
24072412
dbt.fail("Conn", "QueryContext", err)
24082413
}
2409-
result := []driver.Value{0}
2414+
result := []driver.Value{nil}
24102415
err = rows.Next(result)
24112416
if err != nil {
24122417
dbt.fail("Rows", "Next", err)
@@ -2415,12 +2420,16 @@ func TestReset(t *testing.T) {
24152420
if err != nil {
24162421
dbt.fail("Rows", "Close", err)
24172422
}
2418-
if !reflect.DeepEqual([]driver.Value{int64(1)}, result) {
2419-
dbt.Fatalf("failed to set @a to 1 with SET: got %v, want=%v", result, []driver.Value{int64(1)})
2423+
if !(reflect.DeepEqual([]driver.Value{int64(1)}, result) ||
2424+
reflect.DeepEqual([]driver.Value{[]byte("1")}, result)) {
2425+
dbt.Fatalf("failed to set @a to 1 with SET: got %v, want int64(1) or []byte(\"1\")", result)
24202426
}
24212427

24222428
err = c.Reset(ctx)
24232429
if err != nil {
2430+
// Allow skipping on unsupported COM_RESET_CONNECTION
2431+
maybeSkip(t, err, 1047) // ER_UNKNOWN_COM_ERROR
2432+
maybeSkip(t, err, 1235) // ER_NOT_SUPPORTED_YET
24242433
dbt.fail("Conn", "Reset", err)
24252434
}
24262435

0 commit comments

Comments
 (0)