From fd847d4efe57a6d61ad3879a3887b6334c8e928a Mon Sep 17 00:00:00 2001 From: Simon Frei Date: Sun, 28 Jul 2019 22:29:31 +0200 Subject: [PATCH] lib/model: Fix flakyness of TestRequestRemoteRenameChanged (#5904) --- lib/model/requests_test.go | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/lib/model/requests_test.go b/lib/model/requests_test.go index 63fc6c588..97cc8bcdf 100644 --- a/lib/model/requests_test.go +++ b/lib/model/requests_test.go @@ -704,6 +704,8 @@ func TestRequestRemoteRenameChanged(t *testing.T) { } var gotA, gotB, gotConfl bool + bIntermediateVersion := protocol.Vector{}.Update(fc.id.Short()).Update(myID.Short()) + bFinalVersion := bIntermediateVersion.Copy().Update(fc.id.Short()) done = make(chan struct{}) fc.mut.Lock() fc.indexFn = func(folder string, fs []protocol.FileInfo) { @@ -723,7 +725,16 @@ func TestRequestRemoteRenameChanged(t *testing.T) { if gotB { t.Error("Got more than one index update for", f.Name) } - gotB = true + if f.Version.Equal(bIntermediateVersion) { + // This index entry might be superseeded + // by the final one or sent before it separately. + break + } + if f.Version.Equal(bFinalVersion) { + gotB = true + break + } + t.Errorf("Got unexpected version %v for file %v in index update", f.Version, f.Name) case strings.HasPrefix(f.Name, "b.sync-conflict-"): if gotConfl { t.Error("Got more than one index update for conflicts of", f.Name)