fstest: add precision to CompareItems so it works on non-local remotes

This commit is contained in:
Nick Craig-Wood 2019-08-17 10:28:44 +01:00
parent 9f549f848d
commit 743dabf159
2 changed files with 10 additions and 8 deletions

View File

@ -207,9 +207,10 @@ func TestMarch(t *testing.T) {
err := mt.currentError()
require.NoError(t, err)
fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, "srcOnly")
fstest.CompareItems(t, mt.dstOnly, dstOnly, test.dirDstOnly, "dstOnly")
fstest.CompareItems(t, mt.match, match, test.dirMatch, "match")
precision := fs.GetModifyWindow(r.Fremote, r.Flocal)
fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, precision, "srcOnly")
fstest.CompareItems(t, mt.dstOnly, dstOnly, test.dirDstOnly, precision, "dstOnly")
fstest.CompareItems(t, mt.match, match, test.dirMatch, precision, "match")
})
}
}
@ -273,8 +274,9 @@ func TestMarchNoTraverse(t *testing.T) {
err := mt.currentError()
require.NoError(t, err)
fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, "srcOnly")
fstest.CompareItems(t, mt.match, match, test.dirMatch, "match")
precision := fs.GetModifyWindow(r.Fremote, r.Flocal)
fstest.CompareItems(t, mt.srcOnly, srcOnly, test.dirSrcOnly, precision, "srcOnly")
fstest.CompareItems(t, mt.match, match, test.dirMatch, precision, "match")
})
}
}

View File

@ -348,10 +348,10 @@ func CheckItems(t *testing.T, f fs.Fs, items ...Item) {
CheckListingWithPrecision(t, f, items, nil, fs.GetModifyWindow(f))
}
// CompareItems compares a set of DirEntries to a slice of items and a lit of dirs
func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDirs []string, what string) {
// CompareItems compares a set of DirEntries to a slice of items and a list of dirs
// The modtimes are compared with the precision supplied
func CompareItems(t *testing.T, entries fs.DirEntries, items []Item, expectedDirs []string, precision time.Duration, what string) {
is := NewItems(items)
precision, _ := time.ParseDuration("1s")
var objs []fs.Object
var dirs []fs.Directory
wantListing1, wantListing2 := makeListingFromItems(items)