lib/model: Correct completion perc. when globalBytes is 0 (#6963)

This commit is contained in:
Simon Frei
2020-09-07 20:03:18 +02:00
committed by GitHub
parent 415adfbae6
commit e19728d8cc
2 changed files with 18 additions and 9 deletions
+17
View File
@@ -4017,6 +4017,23 @@ func testConfigChangeClosesConnections(t *testing.T, expectFirstClosed, expectSe
}
}
func TestCompletionEmptyGlobal(t *testing.T) {
wcfg, fcfg := tmpDefaultWrapper()
m := setupModel(wcfg)
defer cleanupModelAndRemoveDir(m, fcfg.Filesystem().URI())
files := []protocol.FileInfo{{Name: "foo", Version: protocol.Vector{}.Update(myID.Short()), Sequence: 1}}
m.fmut.Lock()
m.folderFiles[fcfg.ID].Update(protocol.LocalDeviceID, files)
m.fmut.Unlock()
files[0].Deleted = true
files[0].Version = files[0].Version.Update(device1.Short())
m.IndexUpdate(device1, fcfg.ID, files)
comp := m.Completion(protocol.LocalDeviceID, fcfg.ID)
if comp.CompletionPct != 95 {
t.Error("Expected completion of 95%, got", comp.CompletionPct)
}
}
func equalStringsInAnyOrder(a, b []string) bool {
if len(a) != len(b) {
return false