github.com/LukasHeimann/cloudfoundrycli/v8@v8.4.4/command/common/internal/help_all_display_test.go (about)

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