Skip to content

Commit 568ce91

Browse files
Kazuyoshi KatothaJeztah
authored andcommitted
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]> (cherry picked from commit 407703f) Signed-off-by: Sebastiaan van Stijn <[email protected]>
1 parent 3787ef4 commit 568ce91

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
@@ -22,6 +22,7 @@ import (
2222
"fmt"
2323
"path/filepath"
2424
"reflect"
25+
"runtime"
2526
"testing"
2627
"time"
2728

@@ -693,7 +694,12 @@ func checkContainerTimestamps(t *testing.T, c *containers.Container, now time.Ti
693694
} else {
694695
// ensure that updatedat is always after createdat
695696
if !c.UpdatedAt.After(c.CreatedAt) {
696-
t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt)
697+
if runtime.GOOS == "windows" && c.UpdatedAt == c.CreatedAt {
698+
// Windows' time.Now resolution is lower than Linux, due to Go.
699+
// https://github.com/golang/go/issues/31160
700+
} else {
701+
t.Fatalf("timestamp for updatedat not after createdat: %v <= %v", c.UpdatedAt, c.CreatedAt)
702+
}
697703
}
698704
}
699705

0 commit comments

Comments
 (0)