diff --git a/ddl/ddl_algorithm_test.go b/ddl/ddl_algorithm_serial_test.go similarity index 89% rename from ddl/ddl_algorithm_test.go rename to ddl/ddl_algorithm_serial_test.go index 444eddc41efe5..be9c87af3a163 100644 --- a/ddl/ddl_algorithm_test.go +++ b/ddl/ddl_algorithm_serial_test.go @@ -15,27 +15,25 @@ package ddl_test import ( - . "github.com/pingcap/check" + "testing" + "github.com/pingcap/tidb/ddl" "github.com/pingcap/tidb/parser/ast" + "github.com/stretchr/testify/require" ) -var _ = Suite(&testDDLAlgorithmSuite{}) - var ( allAlgorithm = []ast.AlgorithmType{ast.AlgorithmTypeCopy, ast.AlgorithmTypeInplace, ast.AlgorithmTypeInstant} ) -type testDDLAlgorithmSuite struct{} - type testCase struct { alterSpec ast.AlterTableSpec supportedAlgorithm []ast.AlgorithmType expectedAlgorithm []ast.AlgorithmType } -func (s *testDDLAlgorithmSuite) TestFindAlterAlgorithm(c *C) { +func TestFindAlterAlgorithm(t *testing.T) { supportedInstantAlgorithms := []ast.AlgorithmType{ast.AlgorithmTypeDefault, ast.AlgorithmTypeCopy, ast.AlgorithmTypeInplace, ast.AlgorithmTypeInstant} expectedInstantAlgorithms := []ast.AlgorithmType{ast.AlgorithmTypeInstant, ast.AlgorithmTypeInstant, ast.AlgorithmTypeInstant, ast.AlgorithmTypeInstant} @@ -77,11 +75,11 @@ func (s *testDDLAlgorithmSuite) TestFindAlterAlgorithm(c *C) { } for _, tc := range testCases { - runAlterAlgorithmTestCases(c, &tc) + runAlterAlgorithmTestCases(t, &tc) } } -func runAlterAlgorithmTestCases(c *C, tc *testCase) { +func runAlterAlgorithmTestCases(t *testing.T, tc *testCase) { unsupported := make([]ast.AlgorithmType, 0, len(allAlgorithm)) Loop: for _, alm := range allAlgorithm { @@ -101,16 +99,16 @@ Loop: for i, alm := range tc.supportedAlgorithm { algorithm, err = ddl.ResolveAlterAlgorithm(&tc.alterSpec, alm) if err != nil { - c.Assert(ddl.ErrAlterOperationNotSupported.Equal(err), IsTrue) + require.True(t, ddl.ErrAlterOperationNotSupported.Equal(err)) } - c.Assert(algorithm, Equals, tc.expectedAlgorithm[i]) + require.Equal(t, tc.expectedAlgorithm[i], algorithm) } // Test unsupported. for _, alm := range unsupported { algorithm, err = ddl.ResolveAlterAlgorithm(&tc.alterSpec, alm) - c.Assert(algorithm, Equals, ast.AlgorithmTypeDefault) - c.Assert(err, NotNil, Commentf("Tp:%v, alm:%s", tc.alterSpec.Tp, alm)) - c.Assert(ddl.ErrAlterOperationNotSupported.Equal(err), IsTrue) + require.Equal(t, ast.AlgorithmTypeDefault, algorithm) + require.Error(t, err) + require.True(t, ddl.ErrAlterOperationNotSupported.Equal(err)) } }