mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-08-31 12:44:02 +03:00
Add mock for net conn
This commit is contained in:
@@ -8,6 +8,7 @@ require (
|
||||
github.com/libp2p/go-reuseport v0.0.2
|
||||
github.com/mccutchen/go-httpbin v1.1.1
|
||||
github.com/pelletier/go-toml v1.8.1
|
||||
github.com/stretchr/objx v0.3.0 // indirect
|
||||
github.com/stretchr/testify v1.7.0
|
||||
golang.org/x/net v0.0.0-20210226172049-e18ecbb05110
|
||||
)
|
||||
|
||||
@@ -16,6 +16,9 @@ github.com/pkg/errors v0.9.1/go.mod h1:bwawxfHBFNV+L2hUp1rHADufV3IMtnDRdf1r5NINE
|
||||
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
|
||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||
github.com/stretchr/objx v0.3.0 h1:NGXK3lHquSN08v5vWalVI/L8XU9hdzE/G6xsrze47As=
|
||||
github.com/stretchr/objx v0.3.0/go.mod h1:qt09Ya8vawLte6SNmTgCsAVtYtaKzEcn8ATUoHMkEqE=
|
||||
github.com/stretchr/testify v1.3.0/go.mod h1:M5WIy9Dh21IEIfnGCwXGc5bZfKNJtfHm1UVUgZn+9EI=
|
||||
github.com/stretchr/testify v1.5.1/go.mod h1:5W2xD1RspED5o8YsWQXVCued0rvSQ+mT+I5cxcmMvtA=
|
||||
github.com/stretchr/testify v1.7.0 h1:nwc3DEeHmmLAfoZucVR881uASk0Mfjw8xYJ99tb5CcY=
|
||||
github.com/stretchr/testify v1.7.0/go.mod h1:6Fq8oRcR53rry900zMqJjRRixrwX3KX962/h/Wwjteg=
|
||||
|
||||
@@ -5,12 +5,53 @@ import (
|
||||
"net"
|
||||
"net/http/httptest"
|
||||
"strings"
|
||||
"time"
|
||||
|
||||
"github.com/mccutchen/go-httpbin/httpbin"
|
||||
"github.com/stretchr/testify/mock"
|
||||
"github.com/stretchr/testify/suite"
|
||||
)
|
||||
|
||||
type ConnMock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
func (c *ConnMock) Read(b []byte) (int, error) {
|
||||
args := c.Called(b)
|
||||
|
||||
return args.Int(0), args.Error(1)
|
||||
}
|
||||
|
||||
func (c *ConnMock) Write(b []byte) (int, error) {
|
||||
args := c.Called(b)
|
||||
|
||||
return args.Int(0), args.Error(1)
|
||||
}
|
||||
|
||||
func (c *ConnMock) Close() error {
|
||||
return c.Called().Error(0)
|
||||
}
|
||||
|
||||
func (c *ConnMock) LocalAddr() net.Addr {
|
||||
return c.Called().Get(0).(net.Addr)
|
||||
}
|
||||
|
||||
func (c *ConnMock) RemoteAddr() net.Addr {
|
||||
return c.Called().Get(0).(net.Addr)
|
||||
}
|
||||
|
||||
func (c *ConnMock) SetDeadline(t time.Time) error {
|
||||
return c.Called(t).Error(0)
|
||||
}
|
||||
|
||||
func (c *ConnMock) SetReadDeadline(t time.Time) error {
|
||||
return c.Called(t).Error(0)
|
||||
}
|
||||
|
||||
func (c *ConnMock) SetWriteDeadline(t time.Time) error {
|
||||
return c.Called(t).Error(0)
|
||||
}
|
||||
|
||||
type DialerMock struct {
|
||||
mock.Mock
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user