Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ddl/ddl_algorithm_test.go: migrate test-infra to testify #30268

Merged
merged 6 commits into from
Dec 1, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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))
}
}