forked from p53841790/wheat-cache
feat(storage-gateway): add storage gateway mock
This commit is contained in:
parent
981a3341ef
commit
113185d17c
|
@ -4,9 +4,14 @@ import (
|
|||
"sync"
|
||||
|
||||
"gitee.com/wheat-os/wheatCache/pkg/proto"
|
||||
"github.com/golang/mock/gomock"
|
||||
)
|
||||
|
||||
var (
|
||||
oneGatewayClient sync.Once
|
||||
gatewayClient proto.CommServerClient
|
||||
)
|
||||
|
||||
var (
|
||||
GateWayCtrl *gomock.Controller
|
||||
)
|
||||
|
|
|
@ -5,10 +5,22 @@ import (
|
|||
|
||||
"gitee.com/wheat-os/wheatCache/client"
|
||||
"gitee.com/wheat-os/wheatCache/client/middle"
|
||||
_ "gitee.com/wheat-os/wheatCache/conf"
|
||||
mockClient "gitee.com/wheat-os/wheatCache/mock/storage"
|
||||
"gitee.com/wheat-os/wheatCache/pkg/errorx"
|
||||
"gitee.com/wheat-os/wheatCache/pkg/proto"
|
||||
"github.com/spf13/viper"
|
||||
)
|
||||
|
||||
func NewGatewayClient() (proto.CommServerClient, error) {
|
||||
|
||||
if viper.GetString("env") == "dev" {
|
||||
if GateWayCtrl == nil {
|
||||
return nil, errorx.New("mock ctrl not init")
|
||||
}
|
||||
return mockClient.NewMockCommServerClient(GateWayCtrl), nil
|
||||
}
|
||||
|
||||
oneGatewayClient.Do(func() {
|
||||
cli, err := client.NewWheatClient("127.0.0.1:5891", middle.WithUnaryColonyClient)
|
||||
if err == nil {
|
||||
|
|
Loading…
Reference in New Issue