mirror of
https://github.com/octoleo/syncthing.git
synced 2024-12-22 19:08:58 +00:00
lib/model: Fix minor flakiness in TestModTimeWindow
This commit is contained in:
parent
36e6f8b082
commit
5be13f62a2
@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user