From 60f33bd0bd689478bdc8c2214c0ec89ac91990f8 Mon Sep 17 00:00:00 2001 From: Jay Janssen Date: Mon, 1 Jul 2024 10:20:35 -0400 Subject: [PATCH] rename test tables to avoid conflicts --- pkg/checksum/checker_test.go | 32 ++++++++++++++++---------------- pkg/dbconn/conn_test.go | 8 ++++---- 2 files changed, 20 insertions(+), 20 deletions(-) diff --git a/pkg/checksum/checker_test.go b/pkg/checksum/checker_test.go index fb3eda7..76f5d91 100644 --- a/pkg/checksum/checker_test.go +++ b/pkg/checksum/checker_test.go @@ -18,19 +18,19 @@ import ( ) func TestBasicChecksum(t *testing.T) { - testutils.RunSQL(t, "DROP TABLE IF EXISTS t1, _t1_new, _t1_chkpnt") - testutils.RunSQL(t, "CREATE TABLE t1 (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") - testutils.RunSQL(t, "CREATE TABLE _t1_new (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") - testutils.RunSQL(t, "CREATE TABLE _t1_chkpnt (a INT)") // for binlog advancement - testutils.RunSQL(t, "INSERT INTO t1 VALUES (1, 2, 3)") - testutils.RunSQL(t, "INSERT INTO _t1_new VALUES (1, 2, 3)") + testutils.RunSQL(t, "DROP TABLE IF EXISTS basic_checksum, _basic_checksum_new, _basic_checksum_chkpnt") + testutils.RunSQL(t, "CREATE TABLE basic_checksum (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") + testutils.RunSQL(t, "CREATE TABLE _basic_checksum_new (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") + testutils.RunSQL(t, "CREATE TABLE _basic_checksum_chkpnt (a INT)") // for binlog advancement + testutils.RunSQL(t, "INSERT INTO basic_checksum VALUES (1, 2, 3)") + testutils.RunSQL(t, "INSERT INTO _basic_checksum_new VALUES (1, 2, 3)") db, err := dbconn.New(testutils.DSN(), dbconn.NewDBConfig()) assert.NoError(t, err) - t1 := table.NewTableInfo(db, "test", "t1") + t1 := table.NewTableInfo(db, "test", "basic_checksum") assert.NoError(t, t1.SetInfo(context.TODO())) - t2 := table.NewTableInfo(db, "test", "_t1_new") + t2 := table.NewTableInfo(db, "test", "_basic_checksum_new") assert.NoError(t, t2.SetInfo(context.TODO())) logger := logrus.New() @@ -53,19 +53,19 @@ func TestBasicChecksum(t *testing.T) { } func TestBasicValidation(t *testing.T) { - testutils.RunSQL(t, "DROP TABLE IF EXISTS t1, t2, _t1_chkpnt") - testutils.RunSQL(t, "CREATE TABLE t1 (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") - testutils.RunSQL(t, "CREATE TABLE t2 (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") - testutils.RunSQL(t, "CREATE TABLE _t1_chkpnt (a INT)") // for binlog advancement - testutils.RunSQL(t, "INSERT INTO t1 VALUES (1, 2, 3)") - testutils.RunSQL(t, "INSERT INTO t2 VALUES (1, 2, 3)") + testutils.RunSQL(t, "DROP TABLE IF EXISTS basic_validation, basic_validation2, _basic_validation_chkpnt") + testutils.RunSQL(t, "CREATE TABLE basic_validation (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") + testutils.RunSQL(t, "CREATE TABLE basic_validation2 (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") + testutils.RunSQL(t, "CREATE TABLE _basic_validation_chkpnt (a INT)") // for binlog advancement + testutils.RunSQL(t, "INSERT INTO basic_validation VALUES (1, 2, 3)") + testutils.RunSQL(t, "INSERT INTO basic_validation2 VALUES (1, 2, 3)") db, err := dbconn.New(testutils.DSN(), dbconn.NewDBConfig()) assert.NoError(t, err) - t1 := table.NewTableInfo(db, "test", "t1") + t1 := table.NewTableInfo(db, "test", "basic_validation") assert.NoError(t, t1.SetInfo(context.TODO())) - t2 := table.NewTableInfo(db, "test", "t2") + t2 := table.NewTableInfo(db, "test", "basic_validation2") assert.NoError(t, t2.SetInfo(context.TODO())) logger := logrus.New() diff --git a/pkg/dbconn/conn_test.go b/pkg/dbconn/conn_test.go index 96f113e..9d5b604 100644 --- a/pkg/dbconn/conn_test.go +++ b/pkg/dbconn/conn_test.go @@ -61,8 +61,8 @@ func TestNewConn(t *testing.T) { } func TestNewConnRejectsReadOnlyConnections(t *testing.T) { - testutils.RunSQL(t, "DROP TABLE IF EXISTS t1") - testutils.RunSQL(t, "CREATE TABLE t1 (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") + testutils.RunSQL(t, "DROP TABLE IF EXISTS conn_read_only") + testutils.RunSQL(t, "CREATE TABLE conn_read_only (a INT NOT NULL, b INT, c INT, PRIMARY KEY (a))") config := NewDBConfig() // Setting the connection pool size = 1 && transaction_read_only = 1 for the session. @@ -77,11 +77,11 @@ func TestNewConnRejectsReadOnlyConnections(t *testing.T) { // This would error, but `database/sql` automatically retries on a // new connection which is not read-only, and eventually succeed. // See also: rejectReadOnly test in `go-sql-driver/mysql`: https://github.com/go-sql-driver/mysql/blob/52c1917d99904701db2b0e4f14baffa948009cd7/driver_test.go#L2270-L2301 - _, err = db.Exec("insert into t1 values (1, 2, 3)") + _, err = db.Exec("insert into conn_read_only values (1, 2, 3)") assert.NoError(t, err) var count int - err = db.QueryRow("select count(*) from t1 where a = 1").Scan(&count) + err = db.QueryRow("select count(*) from conn_read_only where a = 1").Scan(&count) assert.NoError(t, err) assert.Equal(t, 1, count) }