Skip to content

Commit

Permalink
executor: migrate test-infra to testify for pkg_test
Browse files Browse the repository at this point in the history
Signed-off-by: Weizhen Wang <wangweizhen@pingcap.com>
  • Loading branch information
hawkingrei committed Feb 9, 2022
1 parent 1f7c567 commit 5a07790
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 16 deletions.
7 changes: 7 additions & 0 deletions executor/join_pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import (
"github.com/pingcap/tidb/types"
)

var _ = Suite(&pkgTestSuite{})
var _ = SerialSuites(&pkgTestSerialSuite{})

type pkgTestSuite struct{}

type pkgTestSerialSuite struct{}

func (s *pkgTestSerialSuite) TestJoinExec(c *C) {
c.Assert(failpoint.Enable("github.com/pingcap/tidb/executor/testRowContainerSpill", "return(true)"), IsNil)
defer func() { c.Assert(failpoint.Disable("github.com/pingcap/tidb/executor/testRowContainerSpill"), IsNil) }()
Expand Down
24 changes: 8 additions & 16 deletions executor/pkg_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,27 +17,19 @@ package executor
import (
"context"
"fmt"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/expression"
"github.com/pingcap/tidb/parser/ast"
"github.com/pingcap/tidb/parser/mysql"
plannercore "github.com/pingcap/tidb/planner/core"
"github.com/pingcap/tidb/types"
"github.com/pingcap/tidb/util/chunk"
"github.com/pingcap/tidb/util/mock"
"github.com/stretchr/testify/require"
)

var _ = Suite(&pkgTestSuite{})
var _ = SerialSuites(&pkgTestSerialSuite{})

type pkgTestSuite struct {
}

type pkgTestSerialSuite struct {
}

func (s *pkgTestSuite) TestNestedLoopApply(c *C) {
func TestNestedLoopApply(t *testing.T) {
ctx := context.Background()
sctx := mock.NewContext()
col0 := &expression.Column{Index: 0, RetType: types.NewFieldType(mysql.TypeLong)}
Expand Down Expand Up @@ -88,20 +80,20 @@ func (s *pkgTestSuite) TestNestedLoopApply(c *C) {
it := chunk.NewIterator4Chunk(joinChk)
for rowIdx := 1; ; {
err := join.Next(ctx, joinChk)
c.Check(err, IsNil)
require.NoError(t, err)
if joinChk.NumRows() == 0 {
break
}
for row := it.Begin(); row != it.End(); row = it.Next() {
correctResult := fmt.Sprintf("%v %v", rowIdx, rowIdx)
obtainedResult := fmt.Sprintf("%v %v", row.GetInt64(0), row.GetInt64(1))
c.Check(obtainedResult, Equals, correctResult)
require.Equal(t, correctResult, obtainedResult)
rowIdx++
}
}
}

func (s *pkgTestSuite) TestMoveInfoSchemaToFront(c *C) {
func TestMoveInfoSchemaToFront(t *testing.T) {
dbss := [][]string{
{},
{"A", "B", "C", "a", "b", "c"},
Expand All @@ -124,9 +116,9 @@ func (s *pkgTestSuite) TestMoveInfoSchemaToFront(c *C) {
}

for i, dbs := range wanted {
c.Check(len(dbss[i]), Equals, len(dbs))
require.Equal(t, len(dbs), len(dbss[i]))
for j, db := range dbs {
c.Check(dbss[i][j], Equals, db)
require.Equal(t, db, dbss[i][j])
}
}
}

0 comments on commit 5a07790

Please sign in to comment.