Browse Source

relocate mocks

Darien Raymond 7 years ago
parent
commit
5fc606ce9d
4 changed files with 100 additions and 2 deletions
  1. 1 1
      app/router/router_test.go
  2. 2 1
      mocks.go
  3. 0 0
      testing/mocks/dns.go
  4. 97 0
      testing/mocks/proxy.go

+ 1 - 1
app/router/router_test.go

@@ -8,7 +8,7 @@ import (
 	"v2ray.com/core/common"
 	"v2ray.com/core/common/net"
 	"v2ray.com/core/common/session"
-	"v2ray.com/core/features/mocks"
+	"v2ray.com/core/testing/mocks"
 )
 
 func TestSimpleRouter(t *testing.T) {

+ 2 - 1
mocks.go

@@ -2,4 +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/features/mocks/dns.go v2ray.com/core/features/dns Client
+//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

+ 0 - 0
features/mocks/dns.go → testing/mocks/dns.go


+ 97 - 0
testing/mocks/proxy.go

@@ -0,0 +1,97 @@
+// Code generated by MockGen. DO NOT EDIT.
+// Source: v2ray.com/core/proxy (interfaces: Inbound,Outbound)
+
+// Package mocks is a generated GoMock package.
+package mocks
+
+import (
+	context "context"
+	gomock "github.com/golang/mock/gomock"
+	reflect "reflect"
+	net "v2ray.com/core/common/net"
+	vio "v2ray.com/core/common/vio"
+	routing "v2ray.com/core/features/routing"
+	internet "v2ray.com/core/transport/internet"
+)
+
+// MockProxyInbound is a mock of Inbound interface
+type MockProxyInbound struct {
+	ctrl     *gomock.Controller
+	recorder *MockProxyInboundMockRecorder
+}
+
+// MockProxyInboundMockRecorder is the mock recorder for MockProxyInbound
+type MockProxyInboundMockRecorder struct {
+	mock *MockProxyInbound
+}
+
+// NewMockProxyInbound creates a new mock instance
+func NewMockProxyInbound(ctrl *gomock.Controller) *MockProxyInbound {
+	mock := &MockProxyInbound{ctrl: ctrl}
+	mock.recorder = &MockProxyInboundMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use
+func (m *MockProxyInbound) EXPECT() *MockProxyInboundMockRecorder {
+	return m.recorder
+}
+
+// Network mocks base method
+func (m *MockProxyInbound) 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))
+}
+
+// Process mocks base method
+func (m *MockProxyInbound) 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)
+}
+
+// MockProxyOutbound is a mock of Outbound interface
+type MockProxyOutbound struct {
+	ctrl     *gomock.Controller
+	recorder *MockProxyOutboundMockRecorder
+}
+
+// MockProxyOutboundMockRecorder is the mock recorder for MockProxyOutbound
+type MockProxyOutboundMockRecorder struct {
+	mock *MockProxyOutbound
+}
+
+// NewMockProxyOutbound creates a new mock instance
+func NewMockProxyOutbound(ctrl *gomock.Controller) *MockProxyOutbound {
+	mock := &MockProxyOutbound{ctrl: ctrl}
+	mock.recorder = &MockProxyOutboundMockRecorder{mock}
+	return mock
+}
+
+// EXPECT returns an object that allows the caller to indicate expected use
+func (m *MockProxyOutbound) EXPECT() *MockProxyOutboundMockRecorder {
+	return m.recorder
+}
+
+// Process mocks base method
+func (m *MockProxyOutbound) 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)
+}