From 46fb888ea3f9ed086559ff0c86ee13bce6d5e6c3 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Fri, 24 Apr 2026 09:52:27 +0200 Subject: [PATCH] chore(model): deflake TestCompletionEmptyGlobal (#10663) There was a race condition where using IndexUpdate would trigger a pull, which would sync the delete we are looking for, making the completion 100%. By doing the insert directly into the database we are not triggering these things and get the expected completion percentage always. Signed-off-by: Jakob Borg --- lib/model/model_test.go | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/lib/model/model_test.go b/lib/model/model_test.go index 745d14437..516797d87 100644 --- a/lib/model/model_test.go +++ b/lib/model/model_test.go @@ -3783,13 +3783,19 @@ func TestIssue6961(t *testing.T) { } func TestCompletionEmptyGlobal(t *testing.T) { - m, conn, fcfg := setupModelWithConnection(t) + m, _, fcfg := setupModelWithConnection(t) defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI()) + + // Insert a local file files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID.Short()), Sequence: 1}} - m.sdb.Update(fcfg.ID, protocol.LocalDeviceID, files) + must(t, m.sdb.Update(fcfg.ID, protocol.LocalDeviceID, files)) + + // A remote announces it deleted files[0].Deleted = true files[0].Version = files[0].Version.Update(device1.Short()) - must(t, m.IndexUpdate(conn, &protocol.IndexUpdate{Folder: fcfg.ID, Files: files})) + must(t, m.sdb.Update(fcfg.ID, device1, files)) + + // Our completion should be 95% comp := m.testCompletion(protocol.LocalDeviceID, fcfg.ID) if comp.CompletionPct != 95 { t.Error("Expected completion of 95%, got", comp.CompletionPct)