Skip to content

Commit

Permalink
ddl/ddl_algorithm_test.go: migrate test-infra to testify (#30268)
Browse files Browse the repository at this point in the history
  • Loading branch information
HenryZhang-ZHY committed Dec 1, 2021
1 parent 7124e62 commit b5cb933
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions ddl/ddl_algorithm_test.go → ddl/ddl_algorithm_serial_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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}

Expand Down Expand Up @@ -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 {
Expand All @@ -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))
}
}

0 comments on commit b5cb933

Please sign in to comment.