lib/model: Unflake TestRequestReceiveEncryptedLocalNoSend (#7167)

This commit is contained in:
Simon Frei 2020-11-27 20:53:03 +01:00 committed by GitHub
parent 9a9b7002cd
commit 240ae0c14f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 20 deletions

View File

@ -1353,7 +1353,26 @@ func TestRequestReceiveEncryptedLocalNoSend(t *testing.T) {
m := setupModel(w)
defer cleanupModelAndRemoveDir(m, tfs.URI())
fc := &fakeConnection{id: device1, model: m}
files := genFiles(2)
files[1].LocalFlags = protocol.FlagLocalReceiveOnly
m.fmut.RLock()
fset := m.folderFiles[fcfg.ID]
m.fmut.RUnlock()
fset.Update(protocol.LocalDeviceID, files)
indexChan := make(chan []protocol.FileInfo, 1)
done := make(chan struct{})
defer close(done)
fc := &fakeConnection{
id: device1,
model: m,
indexFn: func(_ context.Context, _ string, fs []protocol.FileInfo) {
select {
case indexChan <- fs:
case <-done:
}
},
}
m.AddConnection(fc, protocol.Hello{})
m.ClusterConfig(device1, protocol.ClusterConfig{
Folders: []protocol.Folder{
@ -1370,25 +1389,6 @@ func TestRequestReceiveEncryptedLocalNoSend(t *testing.T) {
},
})
indexChan := make(chan []protocol.FileInfo, 1)
done := make(chan struct{})
defer close(done)
fc.mut.Lock()
fc.indexFn = func(_ context.Context, _ string, fs []protocol.FileInfo) {
select {
case indexChan <- fs:
case <-done:
}
}
fc.mut.Unlock()
files := genFiles(2)
files[1].LocalFlags = protocol.FlagLocalReceiveOnly
m.fmut.RLock()
fset := m.folderFiles[fcfg.ID]
m.fmut.RUnlock()
fset.Update(protocol.LocalDeviceID, files)
select {
case fs := <-indexChan:
if len(fs) != 1 {