MCPcopy Index your code
hub / github.com/devfile/api / SetExecCommandValues

Method SetExecCommandValues

test/v200/utils/common/command_test_utils.go:116–158  ·  view source on GitHub ↗

SetExecCommandValues randomly sets/updates exec command attributes to random values

(command *schema.Command)

Source from the content-addressed store, hash-verified

114
115// SetExecCommandValues randomly sets/updates exec command attributes to random values
116func (testDevFile *TestDevfile) SetExecCommandValues(command *schema.Command) {
117
118 execCommand := command.Exec
119
120 // exec command must be mentioned by a container component
121 execCommand.Component = testDevFile.GetContainerName()
122
123 execCommand.CommandLine = GetRandomString(4, false) + " " + GetRandomString(4, false)
124 LogInfoMessage(fmt.Sprintf("....... commandLine: %s", execCommand.CommandLine))
125
126 // If group already leave it to make sure defaults are not deleted or added
127 if execCommand.Group == nil {
128 if GetRandomDecision(2, 1) {
129 execCommand.Group = testDevFile.addGroup()
130 }
131 }
132
133 if GetBinaryDecision() {
134 execCommand.Label = GetRandomString(12, false)
135 LogInfoMessage(fmt.Sprintf("....... label: %s", execCommand.Label))
136 } else {
137 execCommand.Label = ""
138 }
139
140 if GetBinaryDecision() {
141 execCommand.WorkingDir = "./tmp"
142 LogInfoMessage(fmt.Sprintf("....... WorkingDir: %s", execCommand.WorkingDir))
143 } else {
144 execCommand.WorkingDir = ""
145 }
146
147 value := GetBinaryDecision()
148 execCommand.HotReloadCapable = &value
149 LogInfoMessage(fmt.Sprintf("....... HotReloadCapable: %t", *execCommand.HotReloadCapable))
150
151 if GetBinaryDecision() {
152 execCommand.Env = addEnv(GetRandomNumber(1, 4))
153 } else {
154 execCommand.Env = nil
155 }
156 testDevFile.commandUpdated(*command)
157
158}
159
160// createCompositeCommand creates an empty composite command in a schema structure
161func (testDevFile *TestDevfile) createCompositeCommand() *schema.Command {

Callers 1

AddCommandMethod · 0.95

Calls 9

GetContainerNameMethod · 0.95
addGroupMethod · 0.95
commandUpdatedMethod · 0.95
GetRandomStringFunction · 0.85
LogInfoMessageFunction · 0.85
GetRandomDecisionFunction · 0.85
GetBinaryDecisionFunction · 0.85
addEnvFunction · 0.85
GetRandomNumberFunction · 0.85

Tested by

no test coverage detected