mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
disable logs in unit tests
This commit is contained in:
parent
2012ac3204
commit
82ea0fff17
@ -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
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user