MCPcopy Index your code
hub / github.com/devopsctl/gitlabctl / executeCommand

Method executeCommand

cmd/helpers_for_test.go:106–136  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

104}
105
106func (execT *execTestCmdFlags) executeCommand() (string, testResult) {
107 // build up the command args and flags value
108 var args []string
109 if execT.noParent {
110 args = []string{execT.cmd.Name()}
111 } else {
112 args = []string{execT.cmd.Parent().Name(), execT.cmd.Name()}
113 }
114 if len(execT.args) > 0 {
115 args = append(args, execT.args...)
116 }
117 for k, v := range execT.flagsMap {
118 arg := fmt.Sprintf("--%s=%s", k, v)
119 args = append(args, arg)
120 }
121
122 // NOTE: program exits with error should be captured here
123 stdout, err := executeCommand(rootCmd, args...)
124 if err != nil {
125 // any errors from the executeCommand should go here
126 // and not exit the program with error!
127 return err.Error(), fail
128 }
129
130 // flags must be set back to their default value
131 if err := resetFlagsFromMap(execT.cmd, execT.flagsMap); err != nil {
132 return err.Error(), fail
133 }
134 tInfo(string(pass))
135 return stdout, pass
136}
137
138// A helper to ignore os.Exit(1) errors when running a cobra Command
139func executeCommand(root *cobra.Command,

Callers 15

TestGetProjectsFunction · 0.95
TestDescBranchCmdFunction · 0.95
TestGetMembersFunction · 0.95
TestNewUserFunction · 0.95
TestProtectBranchFunction · 0.95
TestGetUsersFunction · 0.95
TestEditProjectFunction · 0.95
TestDeleteProjectHookFunction · 0.95
TestEditUserFunction · 0.95
TestDescUserFunction · 0.95
TestDeleteTagCmdFunction · 0.95
TestNewSSHKeyFunction · 0.95

Calls 3

executeCommandFunction · 0.85
resetFlagsFromMapFunction · 0.85
tInfoFunction · 0.85

Tested by

no test coverage detected