*: remove dangling gocheck usages (#167)

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

Co-authored-by: disksing <i@disksing.com>
This commit is contained in:
tison 2021-06-25 10:39:23 +08:00 committed by GitHub
parent 0d5c54ffe6
commit 2e98d94911
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
12 changed files with 22 additions and 69 deletions

View File

@ -41,7 +41,6 @@ import (
"testing"
"time"
. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/kvproto/pkg/kvrpcpb"
"github.com/pingcap/tidb/store/mockstore/unistore"
@ -55,11 +54,6 @@ import (
"github.com/tikv/client-go/v2/util"
)
func TestT(t *testing.T) {
CustomVerboseFlag = true
TestingT(t)
}
func TestAsyncCommit(t *testing.T) {
suite.Run(t, new(testAsyncCommitSuite))
}
@ -74,7 +68,7 @@ type testAsyncCommitCommon struct {
func (s *testAsyncCommitCommon) setUpTest() {
if *mockstore.WithTiKV {
s.store = NewTestStoreT(s.T())
s.store = NewTestStore(s.T())
return
}

View File

@ -4,7 +4,6 @@ go 1.16
require (
github.com/ninedraft/israce v0.0.3
github.com/pingcap/check v0.0.0-20200212061837-5e12011dc712
github.com/pingcap/errors v0.11.5-0.20201126102027-b0a155152ca3
github.com/pingcap/failpoint v0.0.0-20210316064728-7acb0f0a3dfd
github.com/pingcap/kvproto v0.0.0-20210611081648-a215b4e61d2f

View File

@ -59,7 +59,7 @@ type testIsolationSuite struct {
}
func (s *testIsolationSuite) SetupSuite() {
s.store = NewTestStoreT(s.T())
s.store = NewTestStore(s.T())
}
func (s *testIsolationSuite) TearDownSuite() {

View File

@ -66,7 +66,7 @@ type testLockSuite struct {
}
func (s *testLockSuite) SetupTest() {
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
}
func (s *testLockSuite) TearDownTest() {

View File

@ -56,7 +56,7 @@ type testSafePointSuite struct {
}
func (s *testSafePointSuite) SetupSuite() {
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
s.prefix = fmt.Sprintf("seek_%d", time.Now().Unix())
}

View File

@ -49,7 +49,7 @@ type testScanMockSuite struct {
}
func (s *testScanMockSuite) TestScanMultipleRegions() {
store := tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
store := tikv.StoreProbe{KVStore: NewTestStore(s.T())}
defer store.Close()
txn, err := store.Begin()
@ -81,7 +81,7 @@ func (s *testScanMockSuite) TestScanMultipleRegions() {
}
func (s *testScanMockSuite) TestReverseScan() {
store := tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
store := tikv.StoreProbe{KVStore: NewTestStore(s.T())}
defer store.Close()
txn, err := store.Begin()

View File

@ -62,7 +62,7 @@ type testScanSuite struct {
}
func (s *testScanSuite) SetupSuite() {
s.store = NewTestStoreT(s.T())
s.store = NewTestStore(s.T())
s.recordPrefix = []byte("prefix")
s.rowNums = append(s.rowNums, 1, scanBatchSize, scanBatchSize+1, scanBatchSize*3)
// Avoid using async commit logic.

View File

@ -63,7 +63,7 @@ type testSnapshotSuite struct {
}
func (s *testSnapshotSuite) SetupSuite() {
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
s.prefix = fmt.Sprintf("snapshot_%d", time.Now().Unix())
s.rowNums = append(s.rowNums, 1, 100, 191)
}

View File

@ -57,7 +57,7 @@ type testStoreSuite struct {
}
func (s *testStoreSuite) SetupTest() {
s.store = tikv.StoreProbe{KVStore: NewTestStoreT(s.T())}
s.store = tikv.StoreProbe{KVStore: NewTestStore(s.T())}
}
func (s *testStoreSuite) TearDownTest() {

View File

@ -59,7 +59,7 @@ type testTiclientSuite struct {
}
func (s *testTiclientSuite) SetupSuite() {
s.store = NewTestStoreT(s.T())
s.store = NewTestStore(s.T())
s.prefix = fmt.Sprintf("ticlient_%d", time.Now().Unix())
}

View File

@ -40,7 +40,6 @@ import (
"testing"
"unsafe"
. "github.com/pingcap/check"
"github.com/pingcap/errors"
"github.com/pingcap/tidb/kv"
txndriver "github.com/pingcap/tidb/store/driver/txn"
@ -57,39 +56,8 @@ var (
pdAddrs = flag.String("pd-addrs", "127.0.0.1:2379", "pd addrs")
)
// NewTestStoreT creates a KVStore for testing purpose.
// It accepts `*testing.T` instead of `check.C`.
func NewTestStoreT(t *testing.T) *tikv.KVStore {
if !flag.Parsed() {
flag.Parse()
}
if *mockstore.WithTiKV {
addrs := strings.Split(*pdAddrs, ",")
pdClient, err := pd.NewClient(addrs, pd.SecurityOption{})
require.Nil(t, err)
var securityConfig config.Security
tlsConfig, err := securityConfig.ToTLSConfig()
require.Nil(t, err)
spKV, err := tikv.NewEtcdSafePointKV(addrs, tlsConfig)
require.Nil(t, err)
store, err := tikv.NewKVStore("test-store", &tikv.CodecPDClient{Client: pdClient}, spKV, tikv.NewRPCClient(securityConfig))
require.Nil(t, err)
err = clearStorage(store)
require.Nil(t, err)
return store
}
client, pdClient, cluster, err := unistore.New("")
require.Nil(t, err)
unistore.BootstrapWithSingleStore(cluster)
store, err := tikv.NewTestTiKVStore(client, pdClient, nil, nil, 0)
require.Nil(t, err)
return store
}
// NewTestStore creates a KVStore for testing purpose.
// TODO: remove it after we get rid of pingcap/check.
func NewTestStore(c *C) *tikv.KVStore {
func NewTestStore(t *testing.T) *tikv.KVStore {
if !flag.Parsed() {
flag.Parse()
}
@ -97,23 +65,23 @@ func NewTestStore(c *C) *tikv.KVStore {
if *mockstore.WithTiKV {
addrs := strings.Split(*pdAddrs, ",")
pdClient, err := pd.NewClient(addrs, pd.SecurityOption{})
c.Assert(err, IsNil)
require.Nil(t, err)
var securityConfig config.Security
tlsConfig, err := securityConfig.ToTLSConfig()
c.Assert(err, IsNil)
require.Nil(t, err)
spKV, err := tikv.NewEtcdSafePointKV(addrs, tlsConfig)
c.Assert(err, IsNil)
require.Nil(t, err)
store, err := tikv.NewKVStore("test-store", &tikv.CodecPDClient{Client: pdClient}, spKV, tikv.NewRPCClient(securityConfig))
c.Assert(err, IsNil)
require.Nil(t, err)
err = clearStorage(store)
c.Assert(err, IsNil)
require.Nil(t, err)
return store
}
client, pdClient, cluster, err := unistore.New("")
c.Assert(err, IsNil)
require.Nil(t, err)
unistore.BootstrapWithSingleStore(cluster)
store, err := tikv.NewTestTiKVStore(client, pdClient, nil, nil, 0)
c.Assert(err, IsNil)
require.Nil(t, err)
return store
}

View File

@ -35,21 +35,13 @@ package tikvrpc
import (
"testing"
. "github.com/pingcap/check"
"github.com/pingcap/kvproto/pkg/tikvpb"
"github.com/stretchr/testify/assert"
)
func TestT(t *testing.T) {
TestingT(t)
}
type testBatchCommand struct{}
var _ = SerialSuites(&testBatchCommand{})
func (s *testBatchCommand) TestBatchResponse(c *C) {
func TestBatchResponse(t *testing.T) {
resp := &tikvpb.BatchCommandsResponse_Response{}
batchResp, err := FromBatchCommandsResponse(resp)
c.Assert(batchResp == nil, IsTrue)
c.Assert(err != nil, IsTrue)
assert.Nil(t, batchResp)
assert.NotNil(t, err)
}