|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"github.com/tal-tech/go-zero/core/contextx"
|
|
|
|
"github.com/tal-tech/go-zero/core/contextx"
|
|
|
|
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
"github.com/tal-tech/go-zero/core/stringx"
|
|
|
|
"github.com/tal-tech/go-zero/core/stringx"
|
|
|
|
"go.etcd.io/etcd/clientv3"
|
|
|
|
"go.etcd.io/etcd/clientv3"
|
|
|
|
"go.etcd.io/etcd/mvcc/mvccpb"
|
|
|
|
"go.etcd.io/etcd/mvcc/mvccpb"
|
|
|
@ -15,6 +16,10 @@ import (
|
|
|
|
|
|
|
|
|
|
|
|
var mockLock sync.Mutex
|
|
|
|
var mockLock sync.Mutex
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
|
|
|
logx.Disable()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
func setMockClient(cli EtcdClient) func() {
|
|
|
|
func setMockClient(cli EtcdClient) func() {
|
|
|
|
mockLock.Lock()
|
|
|
|
mockLock.Lock()
|
|
|
|
NewClient = func([]string) (EtcdClient, error) {
|
|
|
|
NewClient = func([]string) (EtcdClient, error) {
|
|
|
@ -229,16 +234,3 @@ func TestValueOnlyContext(t *testing.T) {
|
|
|
|
ctx.Done()
|
|
|
|
ctx.Done()
|
|
|
|
assert.Nil(t, ctx.Err())
|
|
|
|
assert.Nil(t, ctx.Err())
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
type mockedSharedCalls struct {
|
|
|
|
|
|
|
|
fn func() (interface{}, error)
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c mockedSharedCalls) Do(_ string, fn func() (interface{}, error)) (interface{}, error) {
|
|
|
|
|
|
|
|
return c.fn()
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
func (c mockedSharedCalls) DoEx(_ string, fn func() (interface{}, error)) (interface{}, bool, error) {
|
|
|
|
|
|
|
|
val, err := c.fn()
|
|
|
|
|
|
|
|
return val, true, err
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|