github.com/mook-as/cf-cli@v7.0.0-beta.28.0.20200120190804-b91c115fae48+incompatible/command/common/internal/help_all_display_test.go (about)

     1  // +build V7
     2  
     3  package internal_test
     4  
     5  import (
     6  	"reflect"
     7  	"strings"
     8  
     9  	"code.cloudfoundry.org/cli/command/common"
    10  	"code.cloudfoundry.org/cli/command/common/internal"
    11  	. "github.com/onsi/ginkgo"
    12  	. "github.com/onsi/gomega"
    13  )
    14  
    15  var _ = Describe("test help all display", func() {
    16  	var fromCommandList []string
    17  	var fromHelpAllDisplay []string
    18  
    19  	BeforeEach(func() {
    20  		commandList := common.Commands
    21  		handler := reflect.TypeOf(commandList)
    22  		for i := 0; i < handler.NumField(); i++ {
    23  			fieldTag := handler.Field(i).Tag
    24  			commandName := fieldTag.Get("command")
    25  			if !(strings.HasPrefix(commandName, "v3-") || (commandName == "")) {
    26  				fromCommandList = append(fromCommandList, commandName)
    27  			}
    28  		}
    29  
    30  		for _, category := range internal.HelpCategoryList {
    31  			for _, row := range category.CommandList {
    32  				for _, command := range row {
    33  					if !(strings.HasPrefix(command, "v3-") || (command == "")) {
    34  						fromHelpAllDisplay = append(fromHelpAllDisplay, command)
    35  					}
    36  				}
    37  			}
    38  		}
    39  	})
    40  
    41  	It("lists all commands from command list in at least one category", func() {
    42  		for _, command := range fromCommandList {
    43  			Expect(fromHelpAllDisplay).To(ContainElement(command))
    44  		}
    45  	})
    46  })