un-skip history test and fix golden mismatches

Signed-off-by: Jason Hall <jason@chainguard.dev>
This commit is contained in:
Jason Hall 2022-09-19 10:04:53 -04:00
parent edd51b2288
commit f5e224e940
Failed to extract signature
3 changed files with 20 additions and 14 deletions

View File

@ -44,12 +44,15 @@ func TestNewHistoryCommandErrors(t *testing.T) {
} }
func notUTCTimezone() bool { func notUTCTimezone() bool {
now := time.Now() if _, offset := time.Now().Zone(); offset != 0 {
return now != now.UTC() return true
}
return false
} }
func TestNewHistoryCommandSuccess(t *testing.T) { func TestNewHistoryCommandSuccess(t *testing.T) {
skip.If(t, notUTCTimezone, "expected output requires UTC timezone") skip.If(t, notUTCTimezone, "expected output requires UTC timezone")
testCases := []struct { testCases := []struct {
name string name string
args []string args []string
@ -93,6 +96,8 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) {
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)
@ -101,5 +106,6 @@ func TestNewHistoryCommandSuccess(t *testing.T) {
assert.NilError(t, err) assert.NilError(t, err)
actual := cli.OutBuffer().String() actual := cli.OutBuffer().String()
golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name)) golden.Assert(t, actual, fmt.Sprintf("history-command-success.%s.golden", tc.name))
})
} }
} }