Skip to content

Commit

Permalink
executor: migrate test-infra to testify for metrics_reader_test.go (#…
Browse files Browse the repository at this point in the history
  • Loading branch information
feitian124 authored Feb 19, 2022
1 parent 6277f61 commit 1d32049
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions executor/metrics_reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,17 +17,20 @@ package executor_test
import (
"context"
"fmt"
"testing"

. "github.com/pingcap/check"
"github.com/pingcap/tidb/executor"
"github.com/pingcap/tidb/parser"
"github.com/pingcap/tidb/planner"
plannercore "github.com/pingcap/tidb/planner/core"
"github.com/pingcap/tidb/util/testkit"
"github.com/pingcap/tidb/testkit"
"github.com/stretchr/testify/require"
)

func (s *testSuite7) TestStmtLabel(c *C) {
tk := testkit.NewTestKit(c, s.store)
func TestStmtLabel(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
tk.MustExec("use test")
tk.MustExec("create table label (c1 int primary key, c2 int, c3 int, index (c2))")
for i := 0; i < 10; i++ {
Expand Down Expand Up @@ -60,13 +63,12 @@ func (s *testSuite7) TestStmtLabel(c *C) {
}
for _, tt := range tests {
stmtNode, err := parser.New().ParseOneStmt(tt.sql, "", "")
c.Check(err, IsNil)
require.NoError(t, err)
preprocessorReturn := &plannercore.PreprocessorReturn{}
err = plannercore.Preprocess(tk.Se, stmtNode, plannercore.WithPreprocessorReturn(preprocessorReturn))
c.Check(err, IsNil)
c.Assert(err, IsNil)
_, _, err = planner.Optimize(context.TODO(), tk.Se, stmtNode, preprocessorReturn.InfoSchema)
c.Assert(err, IsNil)
c.Assert(executor.GetStmtLabel(stmtNode), Equals, tt.label)
err = plannercore.Preprocess(tk.Session(), stmtNode, plannercore.WithPreprocessorReturn(preprocessorReturn))
require.NoError(t, err)
_, _, err = planner.Optimize(context.TODO(), tk.Session(), stmtNode, preprocessorReturn.InfoSchema)
require.NoError(t, err)
require.Equal(t, tt.label, executor.GetStmtLabel(stmtNode))
}
}

0 comments on commit 1d32049

Please sign in to comment.