From 240ae0c14fcd9d5f9e05b85db74657b7cbbf9ab1 Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Fri, 27 Nov 2020 20:53:03 +0100 Subject: [PATCH] lib/model: Unflake TestRequestReceiveEncryptedLocalNoSend (#7167) --- lib/model/requests_test.go | 40 +++++++++++++++++++------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/lib/model/requests_test.go b/lib/model/requests_test.go index 747774fcb..67ecbe201 100644 --- a/lib/model/requests_test.go +++ b/lib/model/requests_test.go @@ -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 {