From d42e4c0cc392b3dd35e7ba491aa5d2e9be09ef6f Mon Sep 17 00:00:00 2001 From: Penthaa Patel Date: Mon, 13 Sep 2021 07:16:39 +0530 Subject: [PATCH] expression/aggregation: migrate test-infra to testify for util_test.go (#27913) --- expression/aggregation/main_test.go | 27 +++++++++++++++++++++++++++ expression/aggregation/util_test.go | 21 +++++++++------------ 2 files changed, 36 insertions(+), 12 deletions(-) create mode 100644 expression/aggregation/main_test.go diff --git a/expression/aggregation/main_test.go b/expression/aggregation/main_test.go new file mode 100644 index 0000000000..4078dc6cf4 --- /dev/null +++ b/expression/aggregation/main_test.go @@ -0,0 +1,27 @@ +// Copyright 2021 PingCAP, Inc. +// +// Licensed under the Apache License, Version 2.0 (the "License"); +// you may not use this file except in compliance with the License. +// You may obtain a copy of the License at +// +// http://www.apache.org/licenses/LICENSE-2.0 +// +// Unless required by applicable law or agreed to in writing, software +// distributed under the License is distributed on an "AS IS" BASIS, +// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +// See the License for the specific language governing permissions and +// limitations under the License. + +package aggregation + +import ( + "testing" + + "github.com/pingcap/tidb/util/testbridge" + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + testbridge.WorkaroundGoCheckFlags() + goleak.VerifyTestMain(m) +} diff --git a/expression/aggregation/util_test.go b/expression/aggregation/util_test.go index 00a2f7769c..883cf3d47c 100644 --- a/expression/aggregation/util_test.go +++ b/expression/aggregation/util_test.go @@ -1,22 +1,19 @@ package aggregation import ( + "testing" "time" - "github.com/pingcap/check" "github.com/pingcap/tidb/sessionctx/stmtctx" "github.com/pingcap/tidb/types" + "github.com/stretchr/testify/require" ) -var _ = check.Suite(&testUtilSuite{}) - -type testUtilSuite struct { -} - -func (s *testUtilSuite) TestDistinct(c *check.C) { +func TestDistinct(t *testing.T) { + t.Parallel() sc := &stmtctx.StatementContext{TimeZone: time.Local} dc := createDistinctChecker(sc) - tests := []struct { + testCases := []struct { vals []interface{} expect bool }{ @@ -27,9 +24,9 @@ func (s *testUtilSuite) TestDistinct(c *check.C) { {[]interface{}{1, nil}, true}, {[]interface{}{1, nil}, false}, } - for _, tt := range tests { - d, err := dc.Check(types.MakeDatums(tt.vals...)) - c.Assert(err, check.IsNil) - c.Assert(d, check.Equals, tt.expect) + for _, tc := range testCases { + d, err := dc.Check(types.MakeDatums(tc.vals...)) + require.NoError(t, err) + require.Equal(t, tc.expect, d) } }