Browse Source

update mocks

pull/1343/head
Darien Raymond 6 years ago
parent
commit
9e66f315e6
No known key found for this signature in database
GPG Key ID: 7251FFA14BB18169
  1. 2
      app/log/command/config.pb.go
  2. 2
      app/proxyman/command/command.pb.go
  3. 4
      app/router/router_test.go
  4. 2
      app/stats/command/command.pb.go
  5. 7
      features/errors.generated.go
  6. 7
      features/stats/errors.generated.go
  7. 4
      mocks.go
  8. 46
      testing/mocks/dns.go
  9. 62
      testing/mocks/proxy.go

2
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"
)

2
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"

4
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)

2
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"
)

7
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{})
}

7
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{})
}

4
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

46
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))
}

62
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)
}

Loading…
Cancel
Save