MCPcopy Create free account
hub / github.com/devopsctl/gitlabctl / checkFlagExistsInCmd

Function checkFlagExistsInCmd

cmd/helpers_for_test.go:70–76  ·  view source on GitHub ↗

checkFlagExistsInCmd ensures that the command contains the flag that is passed from the test suite. The test suite should always be the source of truth with regards to which flags must exists in the command.

(cmd *cobra.Command, flag string)

Source from the content-addressed store, hash-verified

68// passed from the test suite. The test suite should always be the source of
69// truth with regards to which flags must exists in the command.
70func checkFlagExistsInCmd(cmd *cobra.Command, flag string) error {
71 if cmdFlag := cmd.Flag(flag); cmdFlag == nil {
72 return fmt.Errorf("Unknown flag `%s` for `%s %s`",
73 flag, cmd.Parent().Name(), cmd.Name())
74 }
75 return nil
76}
77
78// resetFlagsFromMap resets each key or flag name from a flags map to it's
79// default value. This can be used for test teardown to ensure that the used

Callers 1

resetFlagsFromMapFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected