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 {"routes status", newRoutesStatusCmd},
17 {"attachments list", newAttachmentsListCmd},
18 {"secrets list", newSecretsListCmd},
19 {"images list", newImagesListCmd},
20 {"backup list", newBackupListCmd},
21 {"auth token list", newTokenListCmd},
22 {"remotes list", newRemotesListCmd},
23 {"pin list", newPinListCmd},
24 {"config show", newConfigShowCmd},
25 {"routes show", newRoutesShowCmd},
26 {"networks list", newNetworksListCmd},
27 {"images tags", newImagesTagsCmd},
28 }
29
30 for _, tc := range commands {
31 t.Run(tc.name, func(t *testing.T) {
32 cmd := tc.builder()
33 f := cmd.Flags().Lookup("json")
34 assert.NotNil(t, f, "command %q should have --json flag", tc.name)
35 })
36 }
37}