Ver Fonte

lib/model: Unflake TestRequestReceiveEncryptedLocalNoSend (#7167)

Simon Frei há 4 anos atrás
pai
commit
240ae0c14f
1 ficheiros alterados com 20 adições e 20 exclusões
  1. 20 20
      lib/model/requests_test.go

+ 20 - 20
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 {