FILE / ScuroNeko/mtg

internal/testlib/net_conn_mock.go

Исходный файл и его история в репозитории.
FILE 4c8925ab65082e1273fbe55cbb5a8bf3ed68d9c0
Files
mtg/internal/testlib/net_conn_mock.go
T
2021-04-09 14:35:04 +03:00

49 lines
939 B
Go

package testlib
import (
"net"
"time"
"github.com/stretchr/testify/mock"
)
type NetConnMock struct {
mock.Mock
}
func (n *NetConnMock) Read(b []byte) (int, error) {
args := n.Called(b)
return args.Int(0), args.Error(1)
}
func (n *NetConnMock) Write(b []byte) (int, error) {
args := n.Called(b)
return args.Int(0), args.Error(1)
}
func (n *NetConnMock) Close() error {
return n.Called().Error(0) // nolint: wrapcheck
}
func (n *NetConnMock) LocalAddr() net.Addr {
return n.Called().Get(0).(net.Addr)
}
func (n *NetConnMock) RemoteAddr() net.Addr {
return n.Called().Get(0).(net.Addr)
}
func (n *NetConnMock) SetDeadline(t time.Time) error {
return n.Called(t).Error(0) // nolint: wrapcheck
}
func (n *NetConnMock) SetReadDeadline(t time.Time) error {
return n.Called(t).Error(0) // nolint: wrapcheck
}
func (n *NetConnMock) SetWriteDeadline(t time.Time) error {
return n.Called(t).Error(0) // nolint: wrapcheck
}