lib/model: Fix flakyness of TestRequestRemoteRenameChanged (#5904)

This commit is contained in:
Simon Frei 2019-07-28 22:29:31 +02:00 committed by Jakob Borg
parent 15e51fc045
commit fd847d4efe
1 changed files with 12 additions and 1 deletions

View File

@ -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)