Fix test failure of truncated time

This commit is contained in:
Daisuke Taniwaki 2018-06-30 01:14:44 +09:00
parent c57cdc1d35
commit 7d4c85b02c
No known key found for this signature in database
GPG Key ID: 04F90B23F84F5E6B

View File

@ -299,15 +299,14 @@ func TestFsStoreAssignedModified(t *testing.T) {
// create an empty assigned file, this is good enough for testing
saveTestSourceFile(t, store, assignedFile, nil)
// round the current time to the nearest second because some file systems do not support sub-second precision.
now := time.Now().Round(time.Second)
// set the timestamps to the current time, so we can compare to result of store.AssignedModified
now := time.Now()
err = store.fs.Chtimes(store.metaPath(assignedFile), now, now)
if err != nil {
t.Fatalf("could not change timestamps, error: %v", err)
}
// for now we hope that the system won't truncate the time to a less precise unit,
// if this test fails on certain systems that may be the reason.
modTime, err := store.AssignedModified()
if err != nil {
t.Fatalf("unable to determine modification time of assigned config source, error: %v", err)