mirror of https://github.com/docker/cli.git
Merge pull request #4532 from thaJeztah/tests_dont_require_utc
force TestNewHistoryCommandSuccess to use UTC timezone
This commit is contained in:
commit
16ac0e7b86
|
@ -11,7 +11,6 @@ import (
|
||||||
"github.com/pkg/errors"
|
"github.com/pkg/errors"
|
||||||
"gotest.tools/v3/assert"
|
"gotest.tools/v3/assert"
|
||||||
"gotest.tools/v3/golden"
|
"gotest.tools/v3/golden"
|
||||||
"gotest.tools/v3/skip"
|
|
||||||
)
|
)
|
||||||
|
|
||||||
func TestNewHistoryCommandErrors(t *testing.T) {
|
func TestNewHistoryCommandErrors(t *testing.T) {
|
||||||
|
@ -43,16 +42,7 @@ func TestNewHistoryCommandErrors(t *testing.T) {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
func notUTCTimezone() bool {
|
|
||||||
if _, offset := time.Now().Zone(); offset != 0 {
|
|
||||||
return true
|
|
||||||
}
|
|
||||||
return false
|
|
||||||
}
|
|
||||||
|
|
||||||
func TestNewHistoryCommandSuccess(t *testing.T) {
|
func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
skip.If(t, notUTCTimezone, "expected output requires UTC timezone")
|
|
||||||
|
|
||||||
testCases := []struct {
|
testCases := []struct {
|
||||||
name string
|
name string
|
||||||
args []string
|
args []string
|
||||||
|
@ -65,6 +55,7 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
return []image.HistoryResponseItem{{
|
return []image.HistoryResponseItem{{
|
||||||
ID: "1234567890123456789",
|
ID: "1234567890123456789",
|
||||||
Created: time.Now().Unix(),
|
Created: time.Now().Unix(),
|
||||||
|
Comment: "none",
|
||||||
}}, nil
|
}}, nil
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
|
@ -98,6 +89,9 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
|
||||||
for _, tc := range testCases {
|
for _, tc := range testCases {
|
||||||
tc := tc
|
tc := tc
|
||||||
t.Run(tc.name, func(t *testing.T) {
|
t.Run(tc.name, func(t *testing.T) {
|
||||||
|
// Set to UTC timezone as timestamps in output are
|
||||||
|
// printed in the current timezone
|
||||||
|
t.Setenv("TZ", "UTC")
|
||||||
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
|
||||||
cmd := NewHistoryCommand(cli)
|
cmd := NewHistoryCommand(cli)
|
||||||
cmd.SetOut(io.Discard)
|
cmd.SetOut(io.Discard)
|
||||||
|
|
|
@ -1,2 +1,2 @@
|
||||||
IMAGE CREATED CREATED BY SIZE COMMENT
|
IMAGE CREATED CREATED BY SIZE COMMENT
|
||||||
123456789012 Less than a second ago 0B
|
123456789012 Less than a second ago 0B none
|
||||||
|
|
Loading…
Reference in New Issue