lib/model: Fix minor flakiness in TestModTimeWindow

This commit is contained in:
Jakob Borg 2020-06-16 06:31:55 +02:00
parent 36e6f8b082
commit 5be13f62a2

View File

@ -3389,36 +3389,40 @@ func TestModTimeWindow(t *testing.T) {
m.ScanFolders()
v := protocol.Vector{}
v = v.Update(myID.Short())
// Get current version
fi, ok := m.CurrentFolderFile("default", name)
if !ok {
t.Fatal("File missing")
}
if !fi.Version.Equal(v) {
t.Fatalf("Got version %v, expected %v", fi.Version, v)
}
v := fi.Version
// Update time on disk 1s
err = tfs.Chtimes(name, time.Now(), modTime.Add(time.Second))
must(t, err)
m.ScanFolders()
// No change due to window
// No change due to within window
fi, _ = m.CurrentFolderFile("default", name)
if !fi.Version.Equal(v) {
t.Fatalf("Got version %v, expected %v", fi.Version, v)
}
// Update to be outside window
err = tfs.Chtimes(name, time.Now(), modTime.Add(2*time.Second))
must(t, err)
m.ScanFolders()
v = v.Update(myID.Short())
// Version should have updated
fi, _ = m.CurrentFolderFile("default", name)
if !fi.Version.Equal(v) {
t.Fatalf("Got version %v, expected %v", fi.Version, v)
if fi.Version.Compare(v) != protocol.Greater {
t.Fatalf("Got result %v, expected %v", fi.Version.Compare(v), protocol.Greater)
}
}