expression/aggregation: migrate test-infra to testify for util_test.go (#27913)

This commit is contained in:
Penthaa Patel
2021-09-13 07:16:39 +05:30
committed by GitHub
parent 93a75d3f93
commit d42e4c0cc3
2 changed files with 36 additions and 12 deletions

View File

@ -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)
}

View File

@ -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)
}
}