diff --git a/br/pkg/summary/collector_test.go b/br/pkg/summary/collector_test.go index f9ae53243c7d5..c2328ee7c2c98 100644 --- a/br/pkg/summary/collector_test.go +++ b/br/pkg/summary/collector_test.go @@ -6,20 +6,13 @@ import ( "testing" "time" - . "github.com/pingcap/check" + "github.com/stretchr/testify/require" "go.uber.org/zap" ) -func TestT(t *testing.T) { - TestingT(t) -} - -var _ = Suite(&testCollectorSuite{}) - -type testCollectorSuite struct { -} +func TestSumDurationInt(t *testing.T) { + t.Parallel() -func (suit *testCollectorSuite) TestSumDurationInt(c *C) { fields := []zap.Field{} logger := func(msg string, fs ...zap.Field) { fields = append(fields, fs...) @@ -33,15 +26,15 @@ func (suit *testCollectorSuite) TestSumDurationInt(c *C) { col.SetSuccessStatus(true) col.Summary("foo") - c.Assert(len(fields), Equals, 7) + require.Equal(t, 7, len(fields)) assertContains := func(field zap.Field) { for _, f := range fields { if f.Key == field.Key { - c.Assert(f, DeepEquals, field) + require.Equal(t, field, f) return } } - c.Error(fields, "do not contain", field) + t.Error(field, "is not in", fields) } assertContains(zap.Duration("a", time.Second)) assertContains(zap.Duration("b", 2*time.Second)) diff --git a/br/pkg/summary/main_test.go b/br/pkg/summary/main_test.go new file mode 100644 index 0000000000000..e1b89ff3d0a0f --- /dev/null +++ b/br/pkg/summary/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 summary + +import ( + "testing" + + "github.com/pingcap/tidb/util/testbridge" + "go.uber.org/goleak" +) + +func TestMain(m *testing.M) { + testbridge.WorkaroundGoCheckFlags() + goleak.VerifyTestMain(m) +}