Skip to content

Commit

Permalink
follow up to #33476
Browse files Browse the repository at this point in the history
Signed-off-by: tison <[email protected]>
  • Loading branch information
tisonkun committed Apr 6, 2022
1 parent e6eaf44 commit 56a1c55
Showing 1 changed file with 7 additions and 12 deletions.
19 changes: 7 additions & 12 deletions util/schemacmp/table_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import (
"strings"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/ddl"
"github.com/pingcap/tidb/parser"
Expand All @@ -32,10 +31,6 @@ import (
"github.com/stretchr/testify/require"
)

func Test(t *testing.T) {
TestingT(t)
}

func toTableInfo(parser *parser.Parser, sctx sessionctx.Context, createTableStmt string) (*model.TableInfo, error) {
node, err := parser.ParseOneStmt(createTableStmt, "", "")
if err != nil {
Expand All @@ -59,7 +54,7 @@ func checkDecodeFieldTypes(t *testing.T, info *model.TableInfo, tt schemacmp.Tab
}

func TestJoinSchemas(t *testing.T) {
parser := parser.New()
p := parser.New()
sctx := mock.NewContext()
testCases := []struct {
name string
Expand Down Expand Up @@ -437,9 +432,9 @@ func TestJoinSchemas(t *testing.T) {
}

for _, tc := range testCases {
tia, err := toTableInfo(parser, sctx, tc.a)
tia, err := toTableInfo(p, sctx, tc.a)
require.NoError(t, err)
tib, err := toTableInfo(parser, sctx, tc.b)
tib, err := toTableInfo(p, sctx, tc.b)
require.NoError(t, err)

a := schemacmp.Encode(tia)
Expand All @@ -448,7 +443,7 @@ func TestJoinSchemas(t *testing.T) {
checkDecodeFieldTypes(t, tib, b)
var j schemacmp.Table
if len(tc.joinErr) == 0 {
tij, err := toTableInfo(parser, sctx, tc.join)
tij, err := toTableInfo(p, sctx, tc.join)
require.NoError(t, err)
j = schemacmp.Encode(tij)
}
Expand Down Expand Up @@ -501,9 +496,9 @@ func TestJoinSchemas(t *testing.T) {
}

func TestTableString(t *testing.T) {
parser := parser.New()
p := parser.New()
sctx := mock.NewContext()
ti, err := toTableInfo(parser, sctx, "CREATE TABLE tb (a INT, b INT)")
ti, err := toTableInfo(p, sctx, "CREATE TABLE tb (a INT, b INT)")
require.NoError(t, err)

charsets := []string{"", mysql.DefaultCharset}
Expand All @@ -515,7 +510,7 @@ func TestTableString(t *testing.T) {
sql := strings.ToLower(schemacmp.Encode(ti).String())
require.Equal(t, charset != "", strings.Contains(sql, "charset"))
require.Equal(t, collate != "", strings.Contains(sql, "collate"))
_, err := toTableInfo(parser, sctx, sql)
_, err := toTableInfo(p, sctx, sql)
require.NoError(t, err)
}
}
Expand Down

0 comments on commit 56a1c55

Please sign in to comment.