|
|
|
@ -8,6 +8,7 @@ import (
|
|
|
|
|
"github.com/golang/mock/gomock"
|
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
|
"github.com/tal-tech/go-zero/core/contextx"
|
|
|
|
|
"github.com/tal-tech/go-zero/core/logx"
|
|
|
|
|
"github.com/tal-tech/go-zero/core/stringx"
|
|
|
|
|
"go.etcd.io/etcd/clientv3"
|
|
|
|
|
"go.etcd.io/etcd/mvcc/mvccpb"
|
|
|
|
@ -15,6 +16,10 @@ import (
|
|
|
|
|
|
|
|
|
|
var mockLock sync.Mutex
|
|
|
|
|
|
|
|
|
|
func init() {
|
|
|
|
|
logx.Disable()
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
func setMockClient(cli EtcdClient) func() {
|
|
|
|
|
mockLock.Lock()
|
|
|
|
|
NewClient = func([]string) (EtcdClient, error) {
|
|
|
|
@ -229,16 +234,3 @@ func TestValueOnlyContext(t *testing.T) {
|
|
|
|
|
ctx.Done()
|
|
|
|
|
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
|
|
|
|
|
}
|
|
|
|
|