From 9e66f315e64641e75dc2716f8c738a2bee8618ff Mon Sep 17 00:00:00 2001 From: Darien Raymond Date: Tue, 23 Oct 2018 22:41:27 +0200 Subject: [PATCH] update mocks --- app/log/command/config.pb.go | 2 +- app/proxyman/command/command.pb.go | 2 +- app/router/router_test.go | 4 +- app/stats/command/command.pb.go | 2 +- features/errors.generated.go | 7 +++- features/stats/errors.generated.go | 7 +++- mocks.go | 4 +- testing/mocks/dns.go | 46 +++++++++++----------- testing/mocks/proxy.go | 62 +++++++++++++++--------------- 9 files changed, 71 insertions(+), 65 deletions(-) diff --git a/app/log/command/config.pb.go b/app/log/command/config.pb.go index b361530c..37b0aaa6 100644 --- a/app/log/command/config.pb.go +++ b/app/log/command/config.pb.go @@ -1,9 +1,9 @@ package command import ( + "context" fmt "fmt" proto "github.com/golang/protobuf/proto" - "context" grpc "google.golang.org/grpc" math "math" ) diff --git a/app/proxyman/command/command.pb.go b/app/proxyman/command/command.pb.go index c711df4b..f69914ef 100644 --- a/app/proxyman/command/command.pb.go +++ b/app/proxyman/command/command.pb.go @@ -1,9 +1,9 @@ package command import ( + "context" fmt "fmt" proto "github.com/golang/protobuf/proto" - "context" grpc "google.golang.org/grpc" math "math" core "v2ray.com/core" diff --git a/app/router/router_test.go b/app/router/router_test.go index 53a8eeac..e49d5c52 100644 --- a/app/router/router_test.go +++ b/app/router/router_test.go @@ -26,7 +26,7 @@ func TestSimpleRouter(t *testing.T) { mockCtl := gomock.NewController(t) defer mockCtl.Finish() - mockDns := mocks.NewMockDNSClient(mockCtl) + mockDns := mocks.NewDNSClient(mockCtl) r := new(Router) common.Must(r.Init(config, mockDns)) @@ -58,7 +58,7 @@ func TestIPOnDemand(t *testing.T) { mockCtl := gomock.NewController(t) defer mockCtl.Finish() - mockDns := mocks.NewMockDNSClient(mockCtl) + mockDns := mocks.NewDNSClient(mockCtl) mockDns.EXPECT().LookupIP(gomock.Eq("v2ray.com")).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes() r := new(Router) diff --git a/app/stats/command/command.pb.go b/app/stats/command/command.pb.go index d9aae2af..5e37bd1f 100644 --- a/app/stats/command/command.pb.go +++ b/app/stats/command/command.pb.go @@ -1,9 +1,9 @@ package command import ( + "context" fmt "fmt" proto "github.com/golang/protobuf/proto" - "context" grpc "google.golang.org/grpc" math "math" ) diff --git a/features/errors.generated.go b/features/errors.generated.go index 3d416f4f..7c1082af 100644 --- a/features/errors.generated.go +++ b/features/errors.generated.go @@ -2,5 +2,8 @@ package features import "v2ray.com/core/common/errors" -type errPathObjHolder struct {} -func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/features/stats/errors.generated.go b/features/stats/errors.generated.go index 79ec4cf1..c2489bea 100644 --- a/features/stats/errors.generated.go +++ b/features/stats/errors.generated.go @@ -2,5 +2,8 @@ package stats import "v2ray.com/core/common/errors" -type errPathObjHolder struct {} -func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) } +type errPathObjHolder struct{} + +func newError(values ...interface{}) *errors.Error { + return errors.New(values...).WithPathObj(errPathObjHolder{}) +} diff --git a/mocks.go b/mocks.go index 5eb8ff0d..743ef8bd 100644 --- a/mocks.go +++ b/mocks.go @@ -2,5 +2,5 @@ package core //go:generate go get -u github.com/golang/mock/gomock //go:generate go install github.com/golang/mock/mockgen -//go:generate mockgen -package mocks -destination v2ray.com/core/testing/mocks/dns.go -mock_names Client=MockDNSClient v2ray.com/core/features/dns Client -//go:generate mockgen -package mocks -destination v2ray.com/core/testing/mocks/proxy.go -mock_names Inbound=MockProxyInbound,Outbound=MockProxyOutbound v2ray.com/core/proxy Inbound,Outbound +//go:generate mockgen -package mocks -destination testing/mocks/dns.go -mock_names Client=DNSClient v2ray.com/core/features/dns Client +//go:generate mockgen -package mocks -destination testing/mocks/proxy.go -mock_names Inbound=ProxyInbound,Outbound=ProxyOutbound v2ray.com/core/proxy Inbound,Outbound diff --git a/testing/mocks/dns.go b/testing/mocks/dns.go index 40c7c1a0..56446501 100644 --- a/testing/mocks/dns.go +++ b/testing/mocks/dns.go @@ -10,43 +10,43 @@ import ( reflect "reflect" ) -// MockDNSClient is a mock of Client interface -type MockDNSClient struct { +// DNSClient is a mock of Client interface +type DNSClient struct { ctrl *gomock.Controller - recorder *MockDNSClientMockRecorder + recorder *DNSClientMockRecorder } -// MockDNSClientMockRecorder is the mock recorder for MockDNSClient -type MockDNSClientMockRecorder struct { - mock *MockDNSClient +// DNSClientMockRecorder is the mock recorder for DNSClient +type DNSClientMockRecorder struct { + mock *DNSClient } -// NewMockDNSClient creates a new mock instance -func NewMockDNSClient(ctrl *gomock.Controller) *MockDNSClient { - mock := &MockDNSClient{ctrl: ctrl} - mock.recorder = &MockDNSClientMockRecorder{mock} +// NewDNSClient creates a new mock instance +func NewDNSClient(ctrl *gomock.Controller) *DNSClient { + mock := &DNSClient{ctrl: ctrl} + mock.recorder = &DNSClientMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use -func (m *MockDNSClient) EXPECT() *MockDNSClientMockRecorder { +func (m *DNSClient) EXPECT() *DNSClientMockRecorder { return m.recorder } // Close mocks base method -func (m *MockDNSClient) Close() error { +func (m *DNSClient) Close() error { ret := m.ctrl.Call(m, "Close") ret0, _ := ret[0].(error) return ret0 } // Close indicates an expected call of Close -func (mr *MockDNSClientMockRecorder) Close() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDNSClient)(nil).Close)) +func (mr *DNSClientMockRecorder) Close() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*DNSClient)(nil).Close)) } // LookupIP mocks base method -func (m *MockDNSClient) LookupIP(arg0 string) ([]net.IP, error) { +func (m *DNSClient) LookupIP(arg0 string) ([]net.IP, error) { ret := m.ctrl.Call(m, "LookupIP", arg0) ret0, _ := ret[0].([]net.IP) ret1, _ := ret[1].(error) @@ -54,30 +54,30 @@ func (m *MockDNSClient) LookupIP(arg0 string) ([]net.IP, error) { } // LookupIP indicates an expected call of LookupIP -func (mr *MockDNSClientMockRecorder) LookupIP(arg0 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*MockDNSClient)(nil).LookupIP), arg0) +func (mr *DNSClientMockRecorder) LookupIP(arg0 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*DNSClient)(nil).LookupIP), arg0) } // Start mocks base method -func (m *MockDNSClient) Start() error { +func (m *DNSClient) Start() error { ret := m.ctrl.Call(m, "Start") ret0, _ := ret[0].(error) return ret0 } // Start indicates an expected call of Start -func (mr *MockDNSClientMockRecorder) Start() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockDNSClient)(nil).Start)) +func (mr *DNSClientMockRecorder) Start() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*DNSClient)(nil).Start)) } // Type mocks base method -func (m *MockDNSClient) Type() interface{} { +func (m *DNSClient) Type() interface{} { ret := m.ctrl.Call(m, "Type") ret0, _ := ret[0].(interface{}) return ret0 } // Type indicates an expected call of Type -func (mr *MockDNSClientMockRecorder) Type() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*MockDNSClient)(nil).Type)) +func (mr *DNSClientMockRecorder) Type() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*DNSClient)(nil).Type)) } diff --git a/testing/mocks/proxy.go b/testing/mocks/proxy.go index c8c9aa21..80b8bb73 100644 --- a/testing/mocks/proxy.go +++ b/testing/mocks/proxy.go @@ -14,84 +14,84 @@ import ( internet "v2ray.com/core/transport/internet" ) -// MockProxyInbound is a mock of Inbound interface -type MockProxyInbound struct { +// ProxyInbound is a mock of Inbound interface +type ProxyInbound struct { ctrl *gomock.Controller - recorder *MockProxyInboundMockRecorder + recorder *ProxyInboundMockRecorder } -// MockProxyInboundMockRecorder is the mock recorder for MockProxyInbound -type MockProxyInboundMockRecorder struct { - mock *MockProxyInbound +// ProxyInboundMockRecorder is the mock recorder for ProxyInbound +type ProxyInboundMockRecorder struct { + mock *ProxyInbound } -// NewMockProxyInbound creates a new mock instance -func NewMockProxyInbound(ctrl *gomock.Controller) *MockProxyInbound { - mock := &MockProxyInbound{ctrl: ctrl} - mock.recorder = &MockProxyInboundMockRecorder{mock} +// NewProxyInbound creates a new mock instance +func NewProxyInbound(ctrl *gomock.Controller) *ProxyInbound { + mock := &ProxyInbound{ctrl: ctrl} + mock.recorder = &ProxyInboundMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use -func (m *MockProxyInbound) EXPECT() *MockProxyInboundMockRecorder { +func (m *ProxyInbound) EXPECT() *ProxyInboundMockRecorder { return m.recorder } // Network mocks base method -func (m *MockProxyInbound) Network() net.NetworkList { +func (m *ProxyInbound) Network() net.NetworkList { ret := m.ctrl.Call(m, "Network") ret0, _ := ret[0].(net.NetworkList) return ret0 } // Network indicates an expected call of Network -func (mr *MockProxyInboundMockRecorder) Network() *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Network", reflect.TypeOf((*MockProxyInbound)(nil).Network)) +func (mr *ProxyInboundMockRecorder) Network() *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Network", reflect.TypeOf((*ProxyInbound)(nil).Network)) } // Process mocks base method -func (m *MockProxyInbound) Process(arg0 context.Context, arg1 net.Network, arg2 internet.Connection, arg3 routing.Dispatcher) error { +func (m *ProxyInbound) Process(arg0 context.Context, arg1 net.Network, arg2 internet.Connection, arg3 routing.Dispatcher) error { ret := m.ctrl.Call(m, "Process", arg0, arg1, arg2, arg3) ret0, _ := ret[0].(error) return ret0 } // Process indicates an expected call of Process -func (mr *MockProxyInboundMockRecorder) Process(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*MockProxyInbound)(nil).Process), arg0, arg1, arg2, arg3) +func (mr *ProxyInboundMockRecorder) Process(arg0, arg1, arg2, arg3 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*ProxyInbound)(nil).Process), arg0, arg1, arg2, arg3) } -// MockProxyOutbound is a mock of Outbound interface -type MockProxyOutbound struct { +// ProxyOutbound is a mock of Outbound interface +type ProxyOutbound struct { ctrl *gomock.Controller - recorder *MockProxyOutboundMockRecorder + recorder *ProxyOutboundMockRecorder } -// MockProxyOutboundMockRecorder is the mock recorder for MockProxyOutbound -type MockProxyOutboundMockRecorder struct { - mock *MockProxyOutbound +// ProxyOutboundMockRecorder is the mock recorder for ProxyOutbound +type ProxyOutboundMockRecorder struct { + mock *ProxyOutbound } -// NewMockProxyOutbound creates a new mock instance -func NewMockProxyOutbound(ctrl *gomock.Controller) *MockProxyOutbound { - mock := &MockProxyOutbound{ctrl: ctrl} - mock.recorder = &MockProxyOutboundMockRecorder{mock} +// NewProxyOutbound creates a new mock instance +func NewProxyOutbound(ctrl *gomock.Controller) *ProxyOutbound { + mock := &ProxyOutbound{ctrl: ctrl} + mock.recorder = &ProxyOutboundMockRecorder{mock} return mock } // EXPECT returns an object that allows the caller to indicate expected use -func (m *MockProxyOutbound) EXPECT() *MockProxyOutboundMockRecorder { +func (m *ProxyOutbound) EXPECT() *ProxyOutboundMockRecorder { return m.recorder } // Process mocks base method -func (m *MockProxyOutbound) Process(arg0 context.Context, arg1 *vio.Link, arg2 internet.Dialer) error { +func (m *ProxyOutbound) Process(arg0 context.Context, arg1 *vio.Link, arg2 internet.Dialer) error { ret := m.ctrl.Call(m, "Process", arg0, arg1, arg2) ret0, _ := ret[0].(error) return ret0 } // Process indicates an expected call of Process -func (mr *MockProxyOutboundMockRecorder) Process(arg0, arg1, arg2 interface{}) *gomock.Call { - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*MockProxyOutbound)(nil).Process), arg0, arg1, arg2) +func (mr *ProxyOutboundMockRecorder) Process(arg0, arg1, arg2 interface{}) *gomock.Call { + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*ProxyOutbound)(nil).Process), arg0, arg1, arg2) }