lib: Use counterfeiter to mock interfaces in tests (#7375)

This commit is contained in:
Simon Frei
2021-03-03 08:53:50 +01:00
committed by GitHub
parent 7945430e64
commit 3d91f7c975
46 changed files with 8947 additions and 887 deletions

View File

@@ -8,9 +8,7 @@ package testutils
import (
"errors"
"net"
"sync"
"time"
)
var ErrClosed = errors.New("closed")
@@ -60,47 +58,3 @@ type NoopCloser struct{}
func (NoopCloser) Close() error {
return nil
}
// FakeConnectionInfo implements the methods of protocol.Connection that are
// not implemented by protocol.Connection
type FakeConnectionInfo struct {
Name string
}
func (f *FakeConnectionInfo) RemoteAddr() net.Addr {
return &FakeAddr{}
}
func (f *FakeConnectionInfo) Type() string {
return "fake"
}
func (f *FakeConnectionInfo) Crypto() string {
return "fake"
}
func (f *FakeConnectionInfo) Transport() string {
return "fake"
}
func (f *FakeConnectionInfo) Priority() int {
return 9000
}
func (f *FakeConnectionInfo) String() string {
return ""
}
func (f *FakeConnectionInfo) EstablishedAt() time.Time {
return time.Time{}
}
type FakeAddr struct{}
func (FakeAddr) Network() string {
return "network"
}
func (FakeAddr) String() string {
return "address"
}