mirror of
https://github.com/syncthing/syncthing.git
synced 2026-05-24 17:05:05 -04:00
lib: Use counterfeiter to mock interfaces in tests (#7375)
This commit is contained in:
@@ -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"
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user