lib: Use counterfeiter to mock interfaces in tests (#7375)
This commit is contained in:
@@ -4,9 +4,6 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:generate go run ../../proto/scripts/protofmt.go local.proto
|
||||
//go:generate protoc -I ../../ -I . --gogofast_out=. local.proto
|
||||
|
||||
package discover
|
||||
|
||||
import (
|
||||
|
||||
+30
-24
@@ -1,5 +1,5 @@
|
||||
// Code generated by protoc-gen-gogo. DO NOT EDIT.
|
||||
// source: local.proto
|
||||
// source: lib/discover/local.proto
|
||||
|
||||
package discover
|
||||
|
||||
@@ -8,6 +8,7 @@ import (
|
||||
_ "github.com/gogo/protobuf/gogoproto"
|
||||
proto "github.com/gogo/protobuf/proto"
|
||||
github_com_syncthing_syncthing_lib_protocol "github.com/syncthing/syncthing/lib/protocol"
|
||||
_ "github.com/syncthing/syncthing/proto/ext"
|
||||
io "io"
|
||||
math "math"
|
||||
math_bits "math/bits"
|
||||
@@ -25,16 +26,16 @@ var _ = math.Inf
|
||||
const _ = proto.GoGoProtoPackageIsVersion3 // please upgrade the proto package
|
||||
|
||||
type Announce struct {
|
||||
ID github_com_syncthing_syncthing_lib_protocol.DeviceID `protobuf:"bytes,1,opt,name=id,proto3,customtype=github.com/syncthing/syncthing/lib/protocol.DeviceID" json:"id"`
|
||||
Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses,omitempty"`
|
||||
InstanceID int64 `protobuf:"varint,3,opt,name=instance_id,json=instanceId,proto3" json:"instance_id,omitempty"`
|
||||
ID github_com_syncthing_syncthing_lib_protocol.DeviceID `protobuf:"bytes,1,opt,name=id,proto3,customtype=github.com/syncthing/syncthing/lib/protocol.DeviceID" json:"id" xml:"id"`
|
||||
Addresses []string `protobuf:"bytes,2,rep,name=addresses,proto3" json:"addresses" xml:"address"`
|
||||
InstanceID int64 `protobuf:"varint,3,opt,name=instance_id,json=instanceId,proto3" json:"instanceId" xml:"instanceId"`
|
||||
}
|
||||
|
||||
func (m *Announce) Reset() { *m = Announce{} }
|
||||
func (m *Announce) String() string { return proto.CompactTextString(m) }
|
||||
func (*Announce) ProtoMessage() {}
|
||||
func (*Announce) Descriptor() ([]byte, []int) {
|
||||
return fileDescriptor_aaf1a48d01603033, []int{0}
|
||||
return fileDescriptor_18afca46562fdaf4, []int{0}
|
||||
}
|
||||
func (m *Announce) XXX_Unmarshal(b []byte) error {
|
||||
return m.Unmarshal(b)
|
||||
@@ -67,26 +68,31 @@ func init() {
|
||||
proto.RegisterType((*Announce)(nil), "discover.Announce")
|
||||
}
|
||||
|
||||
func init() { proto.RegisterFile("local.proto", fileDescriptor_aaf1a48d01603033) }
|
||||
func init() { proto.RegisterFile("lib/discover/local.proto", fileDescriptor_18afca46562fdaf4) }
|
||||
|
||||
var fileDescriptor_aaf1a48d01603033 = []byte{
|
||||
// 252 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x4c, 0x8e, 0x31, 0x4e, 0x84, 0x40,
|
||||
0x14, 0x86, 0x67, 0x20, 0x31, 0xbb, 0xb3, 0xc6, 0x82, 0x8a, 0x18, 0x33, 0x10, 0x6d, 0xa8, 0xa0,
|
||||
0xd0, 0x0b, 0x48, 0x68, 0xa6, 0xe5, 0x02, 0x06, 0x66, 0x46, 0xf6, 0x25, 0x38, 0x6f, 0xc3, 0xc0,
|
||||
0x26, 0xde, 0xc2, 0x23, 0x78, 0x01, 0xef, 0x41, 0xb9, 0xa5, 0xb1, 0x20, 0x3a, 0x5c, 0xc4, 0x04,
|
||||
0x34, 0xda, 0x7d, 0xef, 0xcb, 0x97, 0xbc, 0x9f, 0xed, 0x5a, 0x94, 0x55, 0x9b, 0x1e, 0x3a, 0xec,
|
||||
0x31, 0xd8, 0x28, 0xb0, 0x12, 0x8f, 0xba, 0xbb, 0xbc, 0xe9, 0xf4, 0x01, 0x6d, 0xb6, 0xe8, 0x7a,
|
||||
0x78, 0xcc, 0x1a, 0x6c, 0x70, 0x39, 0x16, 0x5a, 0xf3, 0xeb, 0x37, 0xca, 0x36, 0xf7, 0xc6, 0xe0,
|
||||
0x60, 0xa4, 0x0e, 0x4a, 0xe6, 0x81, 0x0a, 0x69, 0x4c, 0x93, 0xf3, 0x3c, 0x1f, 0xa7, 0x88, 0x7c,
|
||||
0x4c, 0xd1, 0x5d, 0x03, 0xfd, 0x7e, 0xa8, 0x53, 0x89, 0x4f, 0x99, 0x7d, 0x36, 0xb2, 0xdf, 0x83,
|
||||
0x69, 0xfe, 0x51, 0x0b, 0xf5, 0xfa, 0x42, 0x62, 0x9b, 0x16, 0xfa, 0x08, 0x52, 0x8b, 0xc2, 0x4d,
|
||||
0x91, 0x27, 0x8a, 0xd2, 0x03, 0x15, 0x5c, 0xb1, 0x6d, 0xa5, 0x54, 0xa7, 0xad, 0xd5, 0x36, 0xf4,
|
||||
0x62, 0x3f, 0xd9, 0x96, 0x7f, 0x22, 0xc8, 0xd8, 0x0e, 0x8c, 0xed, 0x2b, 0x23, 0xf5, 0x03, 0xa8,
|
||||
0xd0, 0x8f, 0x69, 0xe2, 0xe7, 0x17, 0x6e, 0x8a, 0x98, 0xf8, 0xd1, 0xa2, 0x28, 0xd9, 0x6f, 0x22,
|
||||
0x54, 0x1e, 0x8f, 0x5f, 0x9c, 0x8c, 0x8e, 0xd3, 0x93, 0xe3, 0xf4, 0xd3, 0x71, 0xf2, 0x32, 0x73,
|
||||
0xf2, 0x3a, 0x73, 0x7a, 0x9a, 0x39, 0x79, 0x9f, 0x39, 0xa9, 0xcf, 0x96, 0x35, 0xb7, 0xdf, 0x01,
|
||||
0x00, 0x00, 0xff, 0xff, 0xbc, 0x46, 0xaf, 0x1d, 0x16, 0x01, 0x00, 0x00,
|
||||
var fileDescriptor_18afca46562fdaf4 = []byte{
|
||||
// 334 bytes of a gzipped FileDescriptorProto
|
||||
0x1f, 0x8b, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x02, 0xff, 0x8c, 0x91, 0x31, 0x6b, 0xe3, 0x30,
|
||||
0x18, 0x86, 0x2d, 0x05, 0x8e, 0x44, 0x77, 0x07, 0x87, 0x27, 0x93, 0x41, 0x0a, 0xbe, 0x0c, 0x81,
|
||||
0x42, 0x3c, 0xb4, 0x53, 0x29, 0x85, 0x1a, 0x2f, 0x1e, 0xba, 0x64, 0xec, 0xd0, 0x10, 0x4b, 0xaa,
|
||||
0x23, 0x70, 0xa4, 0x60, 0x39, 0x21, 0xfd, 0x07, 0x1d, 0x4b, 0xb6, 0x6e, 0xfd, 0x39, 0x19, 0x3d,
|
||||
0x96, 0x0e, 0x82, 0xd8, 0x5b, 0xc6, 0xfc, 0x82, 0x12, 0x25, 0x69, 0x32, 0x76, 0x7b, 0xf5, 0xe8,
|
||||
0x95, 0x78, 0xf8, 0x3e, 0xe4, 0x65, 0x22, 0x09, 0x98, 0xd0, 0x54, 0xcd, 0x79, 0x1e, 0x64, 0x8a,
|
||||
0x8e, 0xb2, 0xfe, 0x34, 0x57, 0x85, 0x72, 0x9b, 0x47, 0xda, 0xfe, 0x9f, 0xf3, 0xa9, 0xd2, 0x81,
|
||||
0xc5, 0xc9, 0xec, 0x29, 0x48, 0x55, 0xaa, 0xec, 0xc1, 0xa6, 0x7d, 0xbd, 0xdd, 0xe2, 0x8b, 0x62,
|
||||
0x1f, 0xfd, 0x37, 0x88, 0x9a, 0x77, 0x52, 0xaa, 0x99, 0xa4, 0xdc, 0x95, 0x08, 0x0a, 0xe6, 0x81,
|
||||
0x0e, 0xe8, 0xfd, 0x09, 0x1f, 0x57, 0x86, 0x38, 0x9f, 0x86, 0x5c, 0xa5, 0xa2, 0x18, 0xcf, 0x92,
|
||||
0x3e, 0x55, 0x93, 0x40, 0x3f, 0x4b, 0x5a, 0x8c, 0x85, 0x4c, 0xcf, 0xd2, 0xce, 0xc9, 0x7e, 0x45,
|
||||
0x55, 0xd6, 0x8f, 0xf8, 0x5c, 0x50, 0x1e, 0x47, 0x95, 0x21, 0x30, 0x8e, 0x36, 0x86, 0x40, 0xc1,
|
||||
0xb6, 0x86, 0x34, 0x17, 0x93, 0xec, 0xda, 0x17, 0xcc, 0x7f, 0x29, 0xbb, 0x60, 0x59, 0x76, 0x61,
|
||||
0x1c, 0x0d, 0xa0, 0x60, 0xee, 0x0d, 0x6a, 0x8d, 0x18, 0xcb, 0xb9, 0xd6, 0x5c, 0x7b, 0xb0, 0xd3,
|
||||
0xe8, 0xb5, 0x42, 0xbc, 0x31, 0xe4, 0x04, 0xb7, 0x86, 0xfc, 0xb5, 0x6f, 0x0f, 0xc4, 0x1f, 0x9c,
|
||||
0xee, 0xdc, 0x21, 0xfa, 0x2d, 0xa4, 0x2e, 0x46, 0x92, 0xf2, 0xa1, 0x60, 0x5e, 0xa3, 0x03, 0x7a,
|
||||
0x8d, 0xf0, 0xb6, 0x32, 0x04, 0xc5, 0x07, 0x6c, 0x15, 0xd0, 0xb1, 0x14, 0xef, 0x54, 0xfe, 0xed,
|
||||
0x55, 0xbe, 0x91, 0xbf, 0x2c, 0xbb, 0x67, 0xfd, 0xc1, 0x59, 0x3b, 0xbc, 0x5f, 0xad, 0xb1, 0x53,
|
||||
0xae, 0xb1, 0xb3, 0xaa, 0x30, 0x28, 0x2b, 0x0c, 0x5e, 0x6b, 0xec, 0xbc, 0xd7, 0x18, 0x94, 0x35,
|
||||
0x76, 0x3e, 0x6a, 0xec, 0x3c, 0x5c, 0xfc, 0x60, 0x38, 0xc7, 0xd5, 0x24, 0xbf, 0xec, 0x98, 0x2e,
|
||||
0xbf, 0x02, 0x00, 0x00, 0xff, 0xff, 0xdc, 0xe8, 0x9a, 0xd0, 0xc7, 0x01, 0x00, 0x00,
|
||||
}
|
||||
|
||||
func (m *Announce) Marshal() (dAtA []byte, err error) {
|
||||
|
||||
@@ -1,18 +0,0 @@
|
||||
syntax = "proto3";
|
||||
|
||||
package discover;
|
||||
|
||||
import "repos/protobuf/gogoproto/gogo.proto";
|
||||
|
||||
option (gogoproto.goproto_getters_all) = false;
|
||||
option (gogoproto.sizer_all) = false;
|
||||
option (gogoproto.protosizer_all) = true;
|
||||
option (gogoproto.goproto_unkeyed_all) = false;
|
||||
option (gogoproto.goproto_unrecognized_all) = false;
|
||||
option (gogoproto.goproto_sizecache_all) = false;
|
||||
|
||||
message Announce {
|
||||
bytes id = 1 [(gogoproto.customname) = "ID", (gogoproto.customtype) = "github.com/syncthing/syncthing/lib/protocol.DeviceID", (gogoproto.nullable) = false];
|
||||
repeated string addresses = 2;
|
||||
int64 instance_id = 3 [(gogoproto.customname) = "InstanceID"];
|
||||
}
|
||||
@@ -4,6 +4,8 @@
|
||||
// License, v. 2.0. If a copy of the MPL was not distributed with this file,
|
||||
// You can obtain one at https://mozilla.org/MPL/2.0/.
|
||||
|
||||
//go:generate counterfeiter -o mocks/manager.go --fake-name Manager . Manager
|
||||
|
||||
package discover
|
||||
|
||||
import (
|
||||
|
||||
@@ -0,0 +1,454 @@
|
||||
// Code generated by counterfeiter. DO NOT EDIT.
|
||||
package mocks
|
||||
|
||||
import (
|
||||
"context"
|
||||
"sync"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/discover"
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
)
|
||||
|
||||
type Manager struct {
|
||||
CacheStub func() map[protocol.DeviceID]discover.CacheEntry
|
||||
cacheMutex sync.RWMutex
|
||||
cacheArgsForCall []struct {
|
||||
}
|
||||
cacheReturns struct {
|
||||
result1 map[protocol.DeviceID]discover.CacheEntry
|
||||
}
|
||||
cacheReturnsOnCall map[int]struct {
|
||||
result1 map[protocol.DeviceID]discover.CacheEntry
|
||||
}
|
||||
ChildErrorsStub func() map[string]error
|
||||
childErrorsMutex sync.RWMutex
|
||||
childErrorsArgsForCall []struct {
|
||||
}
|
||||
childErrorsReturns struct {
|
||||
result1 map[string]error
|
||||
}
|
||||
childErrorsReturnsOnCall map[int]struct {
|
||||
result1 map[string]error
|
||||
}
|
||||
ErrorStub func() error
|
||||
errorMutex sync.RWMutex
|
||||
errorArgsForCall []struct {
|
||||
}
|
||||
errorReturns struct {
|
||||
result1 error
|
||||
}
|
||||
errorReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
LookupStub func(context.Context, protocol.DeviceID) ([]string, error)
|
||||
lookupMutex sync.RWMutex
|
||||
lookupArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
arg2 protocol.DeviceID
|
||||
}
|
||||
lookupReturns struct {
|
||||
result1 []string
|
||||
result2 error
|
||||
}
|
||||
lookupReturnsOnCall map[int]struct {
|
||||
result1 []string
|
||||
result2 error
|
||||
}
|
||||
ServeStub func(context.Context) error
|
||||
serveMutex sync.RWMutex
|
||||
serveArgsForCall []struct {
|
||||
arg1 context.Context
|
||||
}
|
||||
serveReturns struct {
|
||||
result1 error
|
||||
}
|
||||
serveReturnsOnCall map[int]struct {
|
||||
result1 error
|
||||
}
|
||||
StringStub func() string
|
||||
stringMutex sync.RWMutex
|
||||
stringArgsForCall []struct {
|
||||
}
|
||||
stringReturns struct {
|
||||
result1 string
|
||||
}
|
||||
stringReturnsOnCall map[int]struct {
|
||||
result1 string
|
||||
}
|
||||
invocations map[string][][]interface{}
|
||||
invocationsMutex sync.RWMutex
|
||||
}
|
||||
|
||||
func (fake *Manager) Cache() map[protocol.DeviceID]discover.CacheEntry {
|
||||
fake.cacheMutex.Lock()
|
||||
ret, specificReturn := fake.cacheReturnsOnCall[len(fake.cacheArgsForCall)]
|
||||
fake.cacheArgsForCall = append(fake.cacheArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.CacheStub
|
||||
fakeReturns := fake.cacheReturns
|
||||
fake.recordInvocation("Cache", []interface{}{})
|
||||
fake.cacheMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Manager) CacheCallCount() int {
|
||||
fake.cacheMutex.RLock()
|
||||
defer fake.cacheMutex.RUnlock()
|
||||
return len(fake.cacheArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) CacheCalls(stub func() map[protocol.DeviceID]discover.CacheEntry) {
|
||||
fake.cacheMutex.Lock()
|
||||
defer fake.cacheMutex.Unlock()
|
||||
fake.CacheStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) CacheReturns(result1 map[protocol.DeviceID]discover.CacheEntry) {
|
||||
fake.cacheMutex.Lock()
|
||||
defer fake.cacheMutex.Unlock()
|
||||
fake.CacheStub = nil
|
||||
fake.cacheReturns = struct {
|
||||
result1 map[protocol.DeviceID]discover.CacheEntry
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) CacheReturnsOnCall(i int, result1 map[protocol.DeviceID]discover.CacheEntry) {
|
||||
fake.cacheMutex.Lock()
|
||||
defer fake.cacheMutex.Unlock()
|
||||
fake.CacheStub = nil
|
||||
if fake.cacheReturnsOnCall == nil {
|
||||
fake.cacheReturnsOnCall = make(map[int]struct {
|
||||
result1 map[protocol.DeviceID]discover.CacheEntry
|
||||
})
|
||||
}
|
||||
fake.cacheReturnsOnCall[i] = struct {
|
||||
result1 map[protocol.DeviceID]discover.CacheEntry
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) ChildErrors() map[string]error {
|
||||
fake.childErrorsMutex.Lock()
|
||||
ret, specificReturn := fake.childErrorsReturnsOnCall[len(fake.childErrorsArgsForCall)]
|
||||
fake.childErrorsArgsForCall = append(fake.childErrorsArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.ChildErrorsStub
|
||||
fakeReturns := fake.childErrorsReturns
|
||||
fake.recordInvocation("ChildErrors", []interface{}{})
|
||||
fake.childErrorsMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Manager) ChildErrorsCallCount() int {
|
||||
fake.childErrorsMutex.RLock()
|
||||
defer fake.childErrorsMutex.RUnlock()
|
||||
return len(fake.childErrorsArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) ChildErrorsCalls(stub func() map[string]error) {
|
||||
fake.childErrorsMutex.Lock()
|
||||
defer fake.childErrorsMutex.Unlock()
|
||||
fake.ChildErrorsStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) ChildErrorsReturns(result1 map[string]error) {
|
||||
fake.childErrorsMutex.Lock()
|
||||
defer fake.childErrorsMutex.Unlock()
|
||||
fake.ChildErrorsStub = nil
|
||||
fake.childErrorsReturns = struct {
|
||||
result1 map[string]error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) ChildErrorsReturnsOnCall(i int, result1 map[string]error) {
|
||||
fake.childErrorsMutex.Lock()
|
||||
defer fake.childErrorsMutex.Unlock()
|
||||
fake.ChildErrorsStub = nil
|
||||
if fake.childErrorsReturnsOnCall == nil {
|
||||
fake.childErrorsReturnsOnCall = make(map[int]struct {
|
||||
result1 map[string]error
|
||||
})
|
||||
}
|
||||
fake.childErrorsReturnsOnCall[i] = struct {
|
||||
result1 map[string]error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) Error() error {
|
||||
fake.errorMutex.Lock()
|
||||
ret, specificReturn := fake.errorReturnsOnCall[len(fake.errorArgsForCall)]
|
||||
fake.errorArgsForCall = append(fake.errorArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.ErrorStub
|
||||
fakeReturns := fake.errorReturns
|
||||
fake.recordInvocation("Error", []interface{}{})
|
||||
fake.errorMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Manager) ErrorCallCount() int {
|
||||
fake.errorMutex.RLock()
|
||||
defer fake.errorMutex.RUnlock()
|
||||
return len(fake.errorArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) ErrorCalls(stub func() error) {
|
||||
fake.errorMutex.Lock()
|
||||
defer fake.errorMutex.Unlock()
|
||||
fake.ErrorStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) ErrorReturns(result1 error) {
|
||||
fake.errorMutex.Lock()
|
||||
defer fake.errorMutex.Unlock()
|
||||
fake.ErrorStub = nil
|
||||
fake.errorReturns = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) ErrorReturnsOnCall(i int, result1 error) {
|
||||
fake.errorMutex.Lock()
|
||||
defer fake.errorMutex.Unlock()
|
||||
fake.ErrorStub = nil
|
||||
if fake.errorReturnsOnCall == nil {
|
||||
fake.errorReturnsOnCall = make(map[int]struct {
|
||||
result1 error
|
||||
})
|
||||
}
|
||||
fake.errorReturnsOnCall[i] = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) Lookup(arg1 context.Context, arg2 protocol.DeviceID) ([]string, error) {
|
||||
fake.lookupMutex.Lock()
|
||||
ret, specificReturn := fake.lookupReturnsOnCall[len(fake.lookupArgsForCall)]
|
||||
fake.lookupArgsForCall = append(fake.lookupArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
arg2 protocol.DeviceID
|
||||
}{arg1, arg2})
|
||||
stub := fake.LookupStub
|
||||
fakeReturns := fake.lookupReturns
|
||||
fake.recordInvocation("Lookup", []interface{}{arg1, arg2})
|
||||
fake.lookupMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1, arg2)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1, ret.result2
|
||||
}
|
||||
return fakeReturns.result1, fakeReturns.result2
|
||||
}
|
||||
|
||||
func (fake *Manager) LookupCallCount() int {
|
||||
fake.lookupMutex.RLock()
|
||||
defer fake.lookupMutex.RUnlock()
|
||||
return len(fake.lookupArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) LookupCalls(stub func(context.Context, protocol.DeviceID) ([]string, error)) {
|
||||
fake.lookupMutex.Lock()
|
||||
defer fake.lookupMutex.Unlock()
|
||||
fake.LookupStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) LookupArgsForCall(i int) (context.Context, protocol.DeviceID) {
|
||||
fake.lookupMutex.RLock()
|
||||
defer fake.lookupMutex.RUnlock()
|
||||
argsForCall := fake.lookupArgsForCall[i]
|
||||
return argsForCall.arg1, argsForCall.arg2
|
||||
}
|
||||
|
||||
func (fake *Manager) LookupReturns(result1 []string, result2 error) {
|
||||
fake.lookupMutex.Lock()
|
||||
defer fake.lookupMutex.Unlock()
|
||||
fake.LookupStub = nil
|
||||
fake.lookupReturns = struct {
|
||||
result1 []string
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Manager) LookupReturnsOnCall(i int, result1 []string, result2 error) {
|
||||
fake.lookupMutex.Lock()
|
||||
defer fake.lookupMutex.Unlock()
|
||||
fake.LookupStub = nil
|
||||
if fake.lookupReturnsOnCall == nil {
|
||||
fake.lookupReturnsOnCall = make(map[int]struct {
|
||||
result1 []string
|
||||
result2 error
|
||||
})
|
||||
}
|
||||
fake.lookupReturnsOnCall[i] = struct {
|
||||
result1 []string
|
||||
result2 error
|
||||
}{result1, result2}
|
||||
}
|
||||
|
||||
func (fake *Manager) Serve(arg1 context.Context) error {
|
||||
fake.serveMutex.Lock()
|
||||
ret, specificReturn := fake.serveReturnsOnCall[len(fake.serveArgsForCall)]
|
||||
fake.serveArgsForCall = append(fake.serveArgsForCall, struct {
|
||||
arg1 context.Context
|
||||
}{arg1})
|
||||
stub := fake.ServeStub
|
||||
fakeReturns := fake.serveReturns
|
||||
fake.recordInvocation("Serve", []interface{}{arg1})
|
||||
fake.serveMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub(arg1)
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Manager) ServeCallCount() int {
|
||||
fake.serveMutex.RLock()
|
||||
defer fake.serveMutex.RUnlock()
|
||||
return len(fake.serveArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) ServeCalls(stub func(context.Context) error) {
|
||||
fake.serveMutex.Lock()
|
||||
defer fake.serveMutex.Unlock()
|
||||
fake.ServeStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) ServeArgsForCall(i int) context.Context {
|
||||
fake.serveMutex.RLock()
|
||||
defer fake.serveMutex.RUnlock()
|
||||
argsForCall := fake.serveArgsForCall[i]
|
||||
return argsForCall.arg1
|
||||
}
|
||||
|
||||
func (fake *Manager) ServeReturns(result1 error) {
|
||||
fake.serveMutex.Lock()
|
||||
defer fake.serveMutex.Unlock()
|
||||
fake.ServeStub = nil
|
||||
fake.serveReturns = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) ServeReturnsOnCall(i int, result1 error) {
|
||||
fake.serveMutex.Lock()
|
||||
defer fake.serveMutex.Unlock()
|
||||
fake.ServeStub = nil
|
||||
if fake.serveReturnsOnCall == nil {
|
||||
fake.serveReturnsOnCall = make(map[int]struct {
|
||||
result1 error
|
||||
})
|
||||
}
|
||||
fake.serveReturnsOnCall[i] = struct {
|
||||
result1 error
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) String() string {
|
||||
fake.stringMutex.Lock()
|
||||
ret, specificReturn := fake.stringReturnsOnCall[len(fake.stringArgsForCall)]
|
||||
fake.stringArgsForCall = append(fake.stringArgsForCall, struct {
|
||||
}{})
|
||||
stub := fake.StringStub
|
||||
fakeReturns := fake.stringReturns
|
||||
fake.recordInvocation("String", []interface{}{})
|
||||
fake.stringMutex.Unlock()
|
||||
if stub != nil {
|
||||
return stub()
|
||||
}
|
||||
if specificReturn {
|
||||
return ret.result1
|
||||
}
|
||||
return fakeReturns.result1
|
||||
}
|
||||
|
||||
func (fake *Manager) StringCallCount() int {
|
||||
fake.stringMutex.RLock()
|
||||
defer fake.stringMutex.RUnlock()
|
||||
return len(fake.stringArgsForCall)
|
||||
}
|
||||
|
||||
func (fake *Manager) StringCalls(stub func() string) {
|
||||
fake.stringMutex.Lock()
|
||||
defer fake.stringMutex.Unlock()
|
||||
fake.StringStub = stub
|
||||
}
|
||||
|
||||
func (fake *Manager) StringReturns(result1 string) {
|
||||
fake.stringMutex.Lock()
|
||||
defer fake.stringMutex.Unlock()
|
||||
fake.StringStub = nil
|
||||
fake.stringReturns = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) StringReturnsOnCall(i int, result1 string) {
|
||||
fake.stringMutex.Lock()
|
||||
defer fake.stringMutex.Unlock()
|
||||
fake.StringStub = nil
|
||||
if fake.stringReturnsOnCall == nil {
|
||||
fake.stringReturnsOnCall = make(map[int]struct {
|
||||
result1 string
|
||||
})
|
||||
}
|
||||
fake.stringReturnsOnCall[i] = struct {
|
||||
result1 string
|
||||
}{result1}
|
||||
}
|
||||
|
||||
func (fake *Manager) Invocations() map[string][][]interface{} {
|
||||
fake.invocationsMutex.RLock()
|
||||
defer fake.invocationsMutex.RUnlock()
|
||||
fake.cacheMutex.RLock()
|
||||
defer fake.cacheMutex.RUnlock()
|
||||
fake.childErrorsMutex.RLock()
|
||||
defer fake.childErrorsMutex.RUnlock()
|
||||
fake.errorMutex.RLock()
|
||||
defer fake.errorMutex.RUnlock()
|
||||
fake.lookupMutex.RLock()
|
||||
defer fake.lookupMutex.RUnlock()
|
||||
fake.serveMutex.RLock()
|
||||
defer fake.serveMutex.RUnlock()
|
||||
fake.stringMutex.RLock()
|
||||
defer fake.stringMutex.RUnlock()
|
||||
copiedInvocations := map[string][][]interface{}{}
|
||||
for key, value := range fake.invocations {
|
||||
copiedInvocations[key] = value
|
||||
}
|
||||
return copiedInvocations
|
||||
}
|
||||
|
||||
func (fake *Manager) recordInvocation(key string, args []interface{}) {
|
||||
fake.invocationsMutex.Lock()
|
||||
defer fake.invocationsMutex.Unlock()
|
||||
if fake.invocations == nil {
|
||||
fake.invocations = map[string][][]interface{}{}
|
||||
}
|
||||
if fake.invocations[key] == nil {
|
||||
fake.invocations[key] = [][]interface{}{}
|
||||
}
|
||||
fake.invocations[key] = append(fake.invocations[key], args)
|
||||
}
|
||||
|
||||
var _ discover.Manager = new(Manager)
|
||||
Reference in New Issue
Block a user