Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions cli/command/image/history_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ func TestNewHistoryCommandErrors(t *testing.T) {
}

func TestNewHistoryCommandSuccess(t *testing.T) {
// Set to UTC timezone as timestamps in output are
// printed in the current timezone
local := time.Local
time.Local = time.UTC
t.Cleanup(func() {
time.Local = local
})

testCases := []struct {
name string
args []string
Expand Down Expand Up @@ -118,9 +126,6 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
}
for _, tc := range testCases {
t.Run(tc.name, func(t *testing.T) {
// Set to UTC timezone as timestamps in output are
// printed in the current timezone
Comment on lines -121 to -122

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Perhaps it's worth keeping the comment (but can be moved to the new code).

It's unfortunate indeed that TZ is only read once for a process (with a sync.Once) so there's no clean way to override it for a test 🤔

t.Setenv("TZ", "UTC")
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
cmd := newHistoryCommand(cli)
cmd.SetOut(io.Discard)
Expand Down
Loading