Skip to content

Commit 407703f

Browse files
author
Kazuyoshi Kato
committed
Make checkContainerTimestamps less strict on Windows
This assertion is flaky on Windows. Because of Go, Windows' time.Now resolution is lower than Linux. Signed-off-by: Kazuyoshi Kato <[email protected]>
1 parent 1bb39b8 commit 407703f

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

metadata/containers_test.go

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ import (
2121
"errors"
2222
"fmt"
2323
"path/filepath"
24+
"runtime"
2425
"testing"
2526
"time"
2627

@@ -687,7 +688,12 @@ func checkContainerTimestamps(t *testing.T, c *containers.Container, now time.Ti
687688
} else {
688689
// ensure that updatedat is always after createdat
689690
if !c.UpdatedAt.After(c.CreatedAt) {
690-
t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt)
691+
if runtime.GOOS == "windows" && c.UpdatedAt == c.CreatedAt {
692+
// Windows' time.Now resolution is lower than Linux, due to Go.
693+
// https://github.com/golang/go/issues/31160
694+
} else {
695+
t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt)
696+
}
691697
}
692698
}
693699

0 commit comments

Comments
 (0)