mirror of
https://github.com/v2fly/v2ray-core.git
synced 2025-01-01 23:16:23 -05:00
update mocks
This commit is contained in:
parent
4988b5ad9a
commit
9e66f315e6
@ -1,9 +1,9 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
"context"
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
math "math"
|
math "math"
|
||||||
)
|
)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
"context"
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
math "math"
|
math "math"
|
||||||
core "v2ray.com/core"
|
core "v2ray.com/core"
|
||||||
|
@ -26,7 +26,7 @@ func TestSimpleRouter(t *testing.T) {
|
|||||||
mockCtl := gomock.NewController(t)
|
mockCtl := gomock.NewController(t)
|
||||||
defer mockCtl.Finish()
|
defer mockCtl.Finish()
|
||||||
|
|
||||||
mockDns := mocks.NewMockDNSClient(mockCtl)
|
mockDns := mocks.NewDNSClient(mockCtl)
|
||||||
|
|
||||||
r := new(Router)
|
r := new(Router)
|
||||||
common.Must(r.Init(config, mockDns))
|
common.Must(r.Init(config, mockDns))
|
||||||
@ -58,7 +58,7 @@ func TestIPOnDemand(t *testing.T) {
|
|||||||
mockCtl := gomock.NewController(t)
|
mockCtl := gomock.NewController(t)
|
||||||
defer mockCtl.Finish()
|
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()
|
mockDns.EXPECT().LookupIP(gomock.Eq("v2ray.com")).Return([]net.IP{{192, 168, 0, 1}}, nil).AnyTimes()
|
||||||
|
|
||||||
r := new(Router)
|
r := new(Router)
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package command
|
package command
|
||||||
|
|
||||||
import (
|
import (
|
||||||
|
"context"
|
||||||
fmt "fmt"
|
fmt "fmt"
|
||||||
proto "github.com/golang/protobuf/proto"
|
proto "github.com/golang/protobuf/proto"
|
||||||
"context"
|
|
||||||
grpc "google.golang.org/grpc"
|
grpc "google.golang.org/grpc"
|
||||||
math "math"
|
math "math"
|
||||||
)
|
)
|
||||||
|
@ -2,5 +2,8 @@ package features
|
|||||||
|
|
||||||
import "v2ray.com/core/common/errors"
|
import "v2ray.com/core/common/errors"
|
||||||
|
|
||||||
type errPathObjHolder struct {}
|
type errPathObjHolder struct{}
|
||||||
func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
|
|
||||||
|
func newError(values ...interface{}) *errors.Error {
|
||||||
|
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
||||||
|
}
|
||||||
|
@ -2,5 +2,8 @@ package stats
|
|||||||
|
|
||||||
import "v2ray.com/core/common/errors"
|
import "v2ray.com/core/common/errors"
|
||||||
|
|
||||||
type errPathObjHolder struct {}
|
type errPathObjHolder struct{}
|
||||||
func newError(values ...interface{}) *errors.Error { return errors.New(values...).WithPathObj(errPathObjHolder{}) }
|
|
||||||
|
func newError(values ...interface{}) *errors.Error {
|
||||||
|
return errors.New(values...).WithPathObj(errPathObjHolder{})
|
||||||
|
}
|
||||||
|
4
mocks.go
4
mocks.go
@ -2,5 +2,5 @@ package core
|
|||||||
|
|
||||||
//go:generate go get -u github.com/golang/mock/gomock
|
//go:generate go get -u github.com/golang/mock/gomock
|
||||||
//go:generate go install github.com/golang/mock/mockgen
|
//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 testing/mocks/dns.go -mock_names Client=DNSClient 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/proxy.go -mock_names Inbound=ProxyInbound,Outbound=ProxyOutbound v2ray.com/core/proxy Inbound,Outbound
|
||||||
|
@ -10,43 +10,43 @@ import (
|
|||||||
reflect "reflect"
|
reflect "reflect"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockDNSClient is a mock of Client interface
|
// DNSClient is a mock of Client interface
|
||||||
type MockDNSClient struct {
|
type DNSClient struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockDNSClientMockRecorder
|
recorder *DNSClientMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockDNSClientMockRecorder is the mock recorder for MockDNSClient
|
// DNSClientMockRecorder is the mock recorder for DNSClient
|
||||||
type MockDNSClientMockRecorder struct {
|
type DNSClientMockRecorder struct {
|
||||||
mock *MockDNSClient
|
mock *DNSClient
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockDNSClient creates a new mock instance
|
// NewDNSClient creates a new mock instance
|
||||||
func NewMockDNSClient(ctrl *gomock.Controller) *MockDNSClient {
|
func NewDNSClient(ctrl *gomock.Controller) *DNSClient {
|
||||||
mock := &MockDNSClient{ctrl: ctrl}
|
mock := &DNSClient{ctrl: ctrl}
|
||||||
mock.recorder = &MockDNSClientMockRecorder{mock}
|
mock.recorder = &DNSClientMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// 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
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close mocks base method
|
// Close mocks base method
|
||||||
func (m *MockDNSClient) Close() error {
|
func (m *DNSClient) Close() error {
|
||||||
ret := m.ctrl.Call(m, "Close")
|
ret := m.ctrl.Call(m, "Close")
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Close indicates an expected call of Close
|
// Close indicates an expected call of Close
|
||||||
func (mr *MockDNSClientMockRecorder) Close() *gomock.Call {
|
func (mr *DNSClientMockRecorder) Close() *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*MockDNSClient)(nil).Close))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Close", reflect.TypeOf((*DNSClient)(nil).Close))
|
||||||
}
|
}
|
||||||
|
|
||||||
// LookupIP mocks base method
|
// 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)
|
ret := m.ctrl.Call(m, "LookupIP", arg0)
|
||||||
ret0, _ := ret[0].([]net.IP)
|
ret0, _ := ret[0].([]net.IP)
|
||||||
ret1, _ := ret[1].(error)
|
ret1, _ := ret[1].(error)
|
||||||
@ -54,30 +54,30 @@ func (m *MockDNSClient) LookupIP(arg0 string) ([]net.IP, error) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// LookupIP indicates an expected call of LookupIP
|
// LookupIP indicates an expected call of LookupIP
|
||||||
func (mr *MockDNSClientMockRecorder) LookupIP(arg0 interface{}) *gomock.Call {
|
func (mr *DNSClientMockRecorder) LookupIP(arg0 interface{}) *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*MockDNSClient)(nil).LookupIP), arg0)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "LookupIP", reflect.TypeOf((*DNSClient)(nil).LookupIP), arg0)
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start mocks base method
|
// Start mocks base method
|
||||||
func (m *MockDNSClient) Start() error {
|
func (m *DNSClient) Start() error {
|
||||||
ret := m.ctrl.Call(m, "Start")
|
ret := m.ctrl.Call(m, "Start")
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Start indicates an expected call of Start
|
// Start indicates an expected call of Start
|
||||||
func (mr *MockDNSClientMockRecorder) Start() *gomock.Call {
|
func (mr *DNSClientMockRecorder) Start() *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*MockDNSClient)(nil).Start))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Start", reflect.TypeOf((*DNSClient)(nil).Start))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type mocks base method
|
// Type mocks base method
|
||||||
func (m *MockDNSClient) Type() interface{} {
|
func (m *DNSClient) Type() interface{} {
|
||||||
ret := m.ctrl.Call(m, "Type")
|
ret := m.ctrl.Call(m, "Type")
|
||||||
ret0, _ := ret[0].(interface{})
|
ret0, _ := ret[0].(interface{})
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Type indicates an expected call of Type
|
// Type indicates an expected call of Type
|
||||||
func (mr *MockDNSClientMockRecorder) Type() *gomock.Call {
|
func (mr *DNSClientMockRecorder) Type() *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*MockDNSClient)(nil).Type))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Type", reflect.TypeOf((*DNSClient)(nil).Type))
|
||||||
}
|
}
|
||||||
|
@ -14,84 +14,84 @@ import (
|
|||||||
internet "v2ray.com/core/transport/internet"
|
internet "v2ray.com/core/transport/internet"
|
||||||
)
|
)
|
||||||
|
|
||||||
// MockProxyInbound is a mock of Inbound interface
|
// ProxyInbound is a mock of Inbound interface
|
||||||
type MockProxyInbound struct {
|
type ProxyInbound struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockProxyInboundMockRecorder
|
recorder *ProxyInboundMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockProxyInboundMockRecorder is the mock recorder for MockProxyInbound
|
// ProxyInboundMockRecorder is the mock recorder for ProxyInbound
|
||||||
type MockProxyInboundMockRecorder struct {
|
type ProxyInboundMockRecorder struct {
|
||||||
mock *MockProxyInbound
|
mock *ProxyInbound
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockProxyInbound creates a new mock instance
|
// NewProxyInbound creates a new mock instance
|
||||||
func NewMockProxyInbound(ctrl *gomock.Controller) *MockProxyInbound {
|
func NewProxyInbound(ctrl *gomock.Controller) *ProxyInbound {
|
||||||
mock := &MockProxyInbound{ctrl: ctrl}
|
mock := &ProxyInbound{ctrl: ctrl}
|
||||||
mock.recorder = &MockProxyInboundMockRecorder{mock}
|
mock.recorder = &ProxyInboundMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// 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
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network mocks base method
|
// Network mocks base method
|
||||||
func (m *MockProxyInbound) Network() net.NetworkList {
|
func (m *ProxyInbound) Network() net.NetworkList {
|
||||||
ret := m.ctrl.Call(m, "Network")
|
ret := m.ctrl.Call(m, "Network")
|
||||||
ret0, _ := ret[0].(net.NetworkList)
|
ret0, _ := ret[0].(net.NetworkList)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Network indicates an expected call of Network
|
// Network indicates an expected call of Network
|
||||||
func (mr *MockProxyInboundMockRecorder) Network() *gomock.Call {
|
func (mr *ProxyInboundMockRecorder) Network() *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Network", reflect.TypeOf((*MockProxyInbound)(nil).Network))
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Network", reflect.TypeOf((*ProxyInbound)(nil).Network))
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process mocks base method
|
// 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)
|
ret := m.ctrl.Call(m, "Process", arg0, arg1, arg2, arg3)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process indicates an expected call of Process
|
// Process indicates an expected call of Process
|
||||||
func (mr *MockProxyInboundMockRecorder) Process(arg0, arg1, arg2, arg3 interface{}) *gomock.Call {
|
func (mr *ProxyInboundMockRecorder) 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)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*ProxyInbound)(nil).Process), arg0, arg1, arg2, arg3)
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockProxyOutbound is a mock of Outbound interface
|
// ProxyOutbound is a mock of Outbound interface
|
||||||
type MockProxyOutbound struct {
|
type ProxyOutbound struct {
|
||||||
ctrl *gomock.Controller
|
ctrl *gomock.Controller
|
||||||
recorder *MockProxyOutboundMockRecorder
|
recorder *ProxyOutboundMockRecorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// MockProxyOutboundMockRecorder is the mock recorder for MockProxyOutbound
|
// ProxyOutboundMockRecorder is the mock recorder for ProxyOutbound
|
||||||
type MockProxyOutboundMockRecorder struct {
|
type ProxyOutboundMockRecorder struct {
|
||||||
mock *MockProxyOutbound
|
mock *ProxyOutbound
|
||||||
}
|
}
|
||||||
|
|
||||||
// NewMockProxyOutbound creates a new mock instance
|
// NewProxyOutbound creates a new mock instance
|
||||||
func NewMockProxyOutbound(ctrl *gomock.Controller) *MockProxyOutbound {
|
func NewProxyOutbound(ctrl *gomock.Controller) *ProxyOutbound {
|
||||||
mock := &MockProxyOutbound{ctrl: ctrl}
|
mock := &ProxyOutbound{ctrl: ctrl}
|
||||||
mock.recorder = &MockProxyOutboundMockRecorder{mock}
|
mock.recorder = &ProxyOutboundMockRecorder{mock}
|
||||||
return mock
|
return mock
|
||||||
}
|
}
|
||||||
|
|
||||||
// EXPECT returns an object that allows the caller to indicate expected use
|
// 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
|
return m.recorder
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process mocks base method
|
// 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)
|
ret := m.ctrl.Call(m, "Process", arg0, arg1, arg2)
|
||||||
ret0, _ := ret[0].(error)
|
ret0, _ := ret[0].(error)
|
||||||
return ret0
|
return ret0
|
||||||
}
|
}
|
||||||
|
|
||||||
// Process indicates an expected call of Process
|
// Process indicates an expected call of Process
|
||||||
func (mr *MockProxyOutboundMockRecorder) Process(arg0, arg1, arg2 interface{}) *gomock.Call {
|
func (mr *ProxyOutboundMockRecorder) Process(arg0, arg1, arg2 interface{}) *gomock.Call {
|
||||||
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*MockProxyOutbound)(nil).Process), arg0, arg1, arg2)
|
return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "Process", reflect.TypeOf((*ProxyOutbound)(nil).Process), arg0, arg1, arg2)
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user