cli/image: make history test timezone-independent

Signed-off-by: KeelTrace <218190424+keeltrace@users.noreply.github.com>
This commit is contained in:
KeelTrace
2026-09-12 10:01:56 -07:00
parent d306b9d600
commit eb8fab8023
+8 -3
View File
@@ -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
@@ -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
t.Setenv("TZ", "UTC")
cli := test.NewFakeCli(&fakeClient{imageHistoryFunc: tc.imageHistoryFunc})
cmd := newHistoryCommand(cli)
cmd.SetOut(io.Discard)