diff --git a/go/test/endtoend/utils/cmp.go b/go/test/endtoend/utils/cmp.go index a377ed777c8..3811dcc0e41 100644 --- a/go/test/endtoend/utils/cmp.go +++ b/go/test/endtoend/utils/cmp.go @@ -30,12 +30,17 @@ import ( "vitess.io/vitess/go/test/utils" ) +type TestingT interface { + require.TestingT + Helper() +} + type MySQLCompare struct { - t *testing.T + t TestingT MySQLConn, VtConn *mysql.Conn } -func NewMySQLCompare(t *testing.T, vtParams, mysqlParams mysql.ConnParams) (MySQLCompare, error) { +func NewMySQLCompare(t TestingT, vtParams, mysqlParams mysql.ConnParams) (MySQLCompare, error) { ctx := context.Background() vtConn, err := mysql.Connect(ctx, &vtParams) if err != nil { @@ -54,6 +59,10 @@ func NewMySQLCompare(t *testing.T, vtParams, mysqlParams mysql.ConnParams) (MySQ }, nil } +func (mcmp *MySQLCompare) AsT() *testing.T { + return mcmp.t.(*testing.T) +} + func (mcmp *MySQLCompare) Close() { mcmp.VtConn.Close() mcmp.MySQLConn.Close() diff --git a/go/test/endtoend/utils/mysql.go b/go/test/endtoend/utils/mysql.go index 5b6b226f131..b8ac2b9680c 100644 --- a/go/test/endtoend/utils/mysql.go +++ b/go/test/endtoend/utils/mysql.go @@ -21,7 +21,6 @@ import ( "fmt" "os" "path" - "testing" "github.com/stretchr/testify/assert" @@ -132,7 +131,7 @@ func prepareMySQLWithSchema(params mysql.ConnParams, sql string) error { return nil } -func compareVitessAndMySQLResults(t *testing.T, query string, vtQr, mysqlQr *sqltypes.Result, compareColumns bool) { +func compareVitessAndMySQLResults(t TestingT, query string, vtQr, mysqlQr *sqltypes.Result, compareColumns bool) { if vtQr == nil && mysqlQr == nil { return } @@ -188,10 +187,9 @@ func compareVitessAndMySQLResults(t *testing.T, query string, vtQr, mysqlQr *sql t.Error(errStr) } -func compareVitessAndMySQLErrors(t *testing.T, vtErr, mysqlErr error) { +func compareVitessAndMySQLErrors(t TestingT, vtErr, mysqlErr error) { if vtErr != nil && mysqlErr != nil || vtErr == nil && mysqlErr == nil { return } - out := fmt.Sprintf("Vitess and MySQL are not erroring the same way.\nVitess error: %v\nMySQL error: %v", vtErr, mysqlErr) - t.Error(out) + t.Errorf("Vitess and MySQL are not erroring the same way.\nVitess error: %v\nMySQL error: %v", vtErr, mysqlErr) } diff --git a/go/test/endtoend/utils/utils.go b/go/test/endtoend/utils/utils.go index ce10c723c15..bd1e7af64bd 100644 --- a/go/test/endtoend/utils/utils.go +++ b/go/test/endtoend/utils/utils.go @@ -138,7 +138,7 @@ func ExecCompareMySQL(t *testing.T, vtConn, mysqlConn *mysql.Conn, query string) // ExecAllowError executes the given query without failing the test if it produces // an error. The error is returned to the client, along with the result set. -func ExecAllowError(t *testing.T, conn *mysql.Conn, query string) (*sqltypes.Result, error) { +func ExecAllowError(t TestingT, conn *mysql.Conn, query string) (*sqltypes.Result, error) { t.Helper() return conn.ExecuteFetch(query, 1000, true) }