package cli import ( "testing" "github.com/spf13/cobra" "github.com/stretchr/testify/assert" ) func TestAllListCommands_AcceptJSONFlag(t *testing.T) { commands := []struct { name string builder func() *cobra.Command }{ {"images list", newImagesListCmd}, {"backup list", newBackupListCmd}, {"backup volumes list", newVolumeBackupListCmd}, {"backup volumes run", newVolumeBackupRunCmd}, {"backup volumes status", newVolumeBackupStatusCmd}, {"auth token list", newTokenListCmd}, {"remotes list", newRemotesListCmd}, {"daemon config show", newConfigShowCmd}, {"daemon networks", newNetworksCmd}, {"images tags", newImagesTagsCmd}, {"daemon tls", newTLSCmd}, } for _, tc := range commands { t.Run(tc.name, func(t *testing.T) { cmd := tc.builder() f := cmd.Flags().Lookup("json") assert.NotNil(t, f, "command %q should have --json flag", tc.name) }) } }