mirror of
https://github.com/ScuroNeko/mtg.git
synced 2026-09-01 02:04:01 +03:00
FILE / ScuroNeko/mtg
internal/testlib/net_conn_mock.go
Исходный файл и его история в репозитории.
49 lines
939 B
Go
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
|
|
}
|