Skip to content
Merged
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
22 changes: 12 additions & 10 deletions cli/command/system/events_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,24 @@ func TestEventsFormat(t *testing.T) {
})
}
tests := []struct {
name, format string
name string
args []string
}{
{
name: "default",
args: []string{},
},
{
name: "json",
format: "json",
name: "json",
args: []string{"--format", "json"},
},
{
name: "json template",
format: "{{ json . }}",
name: "json template",
args: []string{"--format", "{{ json . }}"},
},
{
name: "json action",
format: "{{ json .Action }}",
name: "json action",
args: []string{"--format", "{{ json .Action }}"},
},
}

Expand All @@ -69,9 +71,9 @@ func TestEventsFormat(t *testing.T) {
return messages, errs
}})
cmd := NewEventsCommand(cli)
if tc.format != "" {
cmd.Flags().Set("format", tc.format)
}
cmd.SetArgs(tc.args)
cmd.SetOut(io.Discard)
cmd.SetErr(io.Discard)
assert.Check(t, cmd.Execute())
out := cli.OutBuffer().String()
assert.Check(t, golden.String(out, fmt.Sprintf("docker-events-%s.golden", strings.ReplaceAll(tc.name, " ", "-"))))
Expand Down
Loading