1package cli
2
3import (
4 "testing"
5
6 "github.com/spf13/cobra"
7 "github.com/stretchr/testify/assert"
8)
9
10func TestAllListCommands_AcceptJSONFlag(t *testing.T) {
11 commands := []struct {
12 name string
13 builder func() *cobra.Command
14 }{
15 {"routes list", newRoutesListCmd},
16 {"attachments list", newAttachmentsListCmd},
17 {"secrets list", newSecretsListCmd},
18 {"images list", newImagesListCmd},
19 {"backup list", newBackupListCmd},
20 {"auth token list", newTokenListCmd},
21 {"remotes list", newRemotesListCmd},
22 {"rollback list", newRollbackListCmd},
23 {"config show", newConfigShowCmd},
24 {"routes show", newRoutesShowCmd},
25 {"networks list", newNetworksListCmd},
26 {"images tags", newImagesTagsCmd},
27 }
28
29 for _, tc := range commands {
30 t.Run(tc.name, func(t *testing.T) {
31 cmd := tc.builder()
32 f := cmd.Flags().Lookup("json")
33 assert.NotNil(t, f, "command %q should have --json flag", tc.name)
34 })
35 }
36}