Skip to content

Commit

Permalink
planner/core: migrate test-infra to testify for integration_test.go (#…
Browse files Browse the repository at this point in the history
…32560)

Signed-off-by: tison <wander4096@gmail.com>

Co-authored-by: Ti Chi Robot <ti-community-prow-bot@tidb.io>
  • Loading branch information
tisonkun and ti-chi-bot authored Feb 23, 2022
1 parent cce1ebd commit a11ece9
Show file tree
Hide file tree
Showing 8 changed files with 6,031 additions and 5,633 deletions.
2,208 changes: 1,293 additions & 915 deletions planner/core/integration_test.go

Large diffs are not rendered by default.

5 changes: 5 additions & 0 deletions planner/core/main_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@ func TestMain(m *testing.M) {
testDataMap.LoadTestSuiteData("testdata", "expression_rewriter_suite")
testDataMap.LoadTestSuiteData("testdata", "partition_pruner")
testDataMap.LoadTestSuiteData("testdata", "plan_suite")
testDataMap.LoadTestSuiteData("testdata", "integration_suite")

indexMergeSuiteData = testDataMap["index_merge_suite"]

Expand Down Expand Up @@ -93,3 +94,7 @@ func GetPartitionPrunerData() testdata.TestData {
func GetPlanSuiteData() testdata.TestData {
return testDataMap["plan_suite"]
}

func GetIntegrationSuiteData() testdata.TestData {
return testDataMap["integration_suite"]
}
2 changes: 1 addition & 1 deletion planner/core/prepare_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1747,7 +1747,7 @@ func TestPrepareForGroupByMultiItems(t *testing.T) {
tk.MustQuery(`execute stmt2 using @v1, @v2`).Check(testkit.Rows("10"))
}

func TestInvisibleIndex(t *testing.T) {
func TestInvisibleIndexPrepare(t *testing.T) {
store, clean := testkit.CreateMockStore(t)
defer clean()
tk := testkit.NewTestKit(t, store)
Expand Down
442 changes: 0 additions & 442 deletions planner/core/testdata/integration_serial_suite_in.json

This file was deleted.

4,275 changes: 0 additions & 4,275 deletions planner/core/testdata/integration_serial_suite_out.json

This file was deleted.

440 changes: 440 additions & 0 deletions planner/core/testdata/integration_suite_in.json

Large diffs are not rendered by default.

4,273 changes: 4,273 additions & 0 deletions planner/core/testdata/integration_suite_out.json

Large diffs are not rendered by default.

19 changes: 19 additions & 0 deletions testkit/result.go
Original file line number Diff line number Diff line change
Expand Up @@ -99,3 +99,22 @@ func (res *Result) Rows() [][]interface{} {
}
return ifacesSlice
}

// CheckAt asserts the result of selected columns equals the expected results.
func (res *Result) CheckAt(cols []int, expected [][]interface{}) {
for _, e := range expected {
res.require.Equal(len(e), len(cols))
}

rows := make([][]string, 0, len(expected))
for i := range res.rows {
row := make([]string, 0, len(cols))
for _, r := range cols {
row = append(row, res.rows[i][r])
}
rows = append(rows, row)
}
got := fmt.Sprintf("%s", rows)
need := fmt.Sprintf("%s", expected)
res.require.Equal(need, got, res.comment)
}

0 comments on commit a11ece9

Please sign in to comment.