all: Refactor the protocol/model interface a bit (ref #8981) (#9007)

This commit is contained in:
Jakob Borg
2023-07-29 10:24:44 +02:00
committed by GitHub
parent b806026990
commit 9d21b91124
21 changed files with 431 additions and 359 deletions
+65 -65
View File
@@ -41,6 +41,16 @@ type Connection struct {
cryptoReturnsOnCall map[int]struct {
result1 string
}
DeviceIDStub func() protocol.DeviceID
deviceIDMutex sync.RWMutex
deviceIDArgsForCall []struct {
}
deviceIDReturns struct {
result1 protocol.DeviceID
}
deviceIDReturnsOnCall map[int]struct {
result1 protocol.DeviceID
}
DownloadProgressStub func(context.Context, string, []protocol.FileDownloadProgressUpdate)
downloadProgressMutex sync.RWMutex
downloadProgressArgsForCall []struct {
@@ -58,16 +68,6 @@ type Connection struct {
establishedAtReturnsOnCall map[int]struct {
result1 time.Time
}
IDStub func() protocol.DeviceID
iDMutex sync.RWMutex
iDArgsForCall []struct {
}
iDReturns struct {
result1 protocol.DeviceID
}
iDReturnsOnCall map[int]struct {
result1 protocol.DeviceID
}
IndexStub func(context.Context, string, []protocol.FileInfo) error
indexMutex sync.RWMutex
indexArgsForCall []struct {
@@ -368,6 +368,59 @@ func (fake *Connection) CryptoReturnsOnCall(i int, result1 string) {
}{result1}
}
func (fake *Connection) DeviceID() protocol.DeviceID {
fake.deviceIDMutex.Lock()
ret, specificReturn := fake.deviceIDReturnsOnCall[len(fake.deviceIDArgsForCall)]
fake.deviceIDArgsForCall = append(fake.deviceIDArgsForCall, struct {
}{})
stub := fake.DeviceIDStub
fakeReturns := fake.deviceIDReturns
fake.recordInvocation("DeviceID", []interface{}{})
fake.deviceIDMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *Connection) DeviceIDCallCount() int {
fake.deviceIDMutex.RLock()
defer fake.deviceIDMutex.RUnlock()
return len(fake.deviceIDArgsForCall)
}
func (fake *Connection) DeviceIDCalls(stub func() protocol.DeviceID) {
fake.deviceIDMutex.Lock()
defer fake.deviceIDMutex.Unlock()
fake.DeviceIDStub = stub
}
func (fake *Connection) DeviceIDReturns(result1 protocol.DeviceID) {
fake.deviceIDMutex.Lock()
defer fake.deviceIDMutex.Unlock()
fake.DeviceIDStub = nil
fake.deviceIDReturns = struct {
result1 protocol.DeviceID
}{result1}
}
func (fake *Connection) DeviceIDReturnsOnCall(i int, result1 protocol.DeviceID) {
fake.deviceIDMutex.Lock()
defer fake.deviceIDMutex.Unlock()
fake.DeviceIDStub = nil
if fake.deviceIDReturnsOnCall == nil {
fake.deviceIDReturnsOnCall = make(map[int]struct {
result1 protocol.DeviceID
})
}
fake.deviceIDReturnsOnCall[i] = struct {
result1 protocol.DeviceID
}{result1}
}
func (fake *Connection) DownloadProgress(arg1 context.Context, arg2 string, arg3 []protocol.FileDownloadProgressUpdate) {
var arg3Copy []protocol.FileDownloadProgressUpdate
if arg3 != nil {
@@ -460,59 +513,6 @@ func (fake *Connection) EstablishedAtReturnsOnCall(i int, result1 time.Time) {
}{result1}
}
func (fake *Connection) ID() protocol.DeviceID {
fake.iDMutex.Lock()
ret, specificReturn := fake.iDReturnsOnCall[len(fake.iDArgsForCall)]
fake.iDArgsForCall = append(fake.iDArgsForCall, struct {
}{})
stub := fake.IDStub
fakeReturns := fake.iDReturns
fake.recordInvocation("ID", []interface{}{})
fake.iDMutex.Unlock()
if stub != nil {
return stub()
}
if specificReturn {
return ret.result1
}
return fakeReturns.result1
}
func (fake *Connection) IDCallCount() int {
fake.iDMutex.RLock()
defer fake.iDMutex.RUnlock()
return len(fake.iDArgsForCall)
}
func (fake *Connection) IDCalls(stub func() protocol.DeviceID) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = stub
}
func (fake *Connection) IDReturns(result1 protocol.DeviceID) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = nil
fake.iDReturns = struct {
result1 protocol.DeviceID
}{result1}
}
func (fake *Connection) IDReturnsOnCall(i int, result1 protocol.DeviceID) {
fake.iDMutex.Lock()
defer fake.iDMutex.Unlock()
fake.IDStub = nil
if fake.iDReturnsOnCall == nil {
fake.iDReturnsOnCall = make(map[int]struct {
result1 protocol.DeviceID
})
}
fake.iDReturnsOnCall[i] = struct {
result1 protocol.DeviceID
}{result1}
}
func (fake *Connection) Index(arg1 context.Context, arg2 string, arg3 []protocol.FileInfo) error {
var arg3Copy []protocol.FileInfo
if arg3 != nil {
@@ -1164,12 +1164,12 @@ func (fake *Connection) Invocations() map[string][][]interface{} {
defer fake.clusterConfigMutex.RUnlock()
fake.cryptoMutex.RLock()
defer fake.cryptoMutex.RUnlock()
fake.deviceIDMutex.RLock()
defer fake.deviceIDMutex.RUnlock()
fake.downloadProgressMutex.RLock()
defer fake.downloadProgressMutex.RUnlock()
fake.establishedAtMutex.RLock()
defer fake.establishedAtMutex.RUnlock()
fake.iDMutex.RLock()
defer fake.iDMutex.RUnlock()
fake.indexMutex.RLock()
defer fake.indexMutex.RUnlock()
fake.indexUpdateMutex.RLock()