expression/aggregation: migrate test-infra to testify for util_test.go (#27913)
This commit is contained in:
27
expression/aggregation/main_test.go
Normal file
27
expression/aggregation/main_test.go
Normal 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)
|
||||
}
|
||||
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user