feat(dao-external): add external mock

This commit is contained in:
bandl 2021-11-21 23:10:14 +08:00
parent 0c8a17b21d
commit a5ef559e14
2 changed files with 9 additions and 2 deletions

View File

@ -14,4 +14,6 @@ var (
var ( var (
GateWayCtrl *gomock.Controller GateWayCtrl *gomock.Controller
mockGatewayClient proto.CommServerClient
oneMockGatewayClient sync.Once
) )

View File

@ -18,7 +18,12 @@ func NewGatewayClient() (proto.CommServerClient, error) {
if GateWayCtrl == nil { if GateWayCtrl == nil {
return nil, errorx.New("mock ctrl not init") return nil, errorx.New("mock ctrl not init")
} }
return mockClient.NewMockCommServerClient(GateWayCtrl), nil
oneMockGatewayClient.Do(func() {
mockGatewayClient = mockClient.NewMockCommServerClient(GateWayCtrl)
})
return mockGatewayClient, nil
} }
oneGatewayClient.Do(func() { oneGatewayClient.Do(func() {