SetExecCommandValues randomly sets/updates exec command attributes to random values
(command *schema.Command)
| 114 | |
| 115 | // SetExecCommandValues randomly sets/updates exec command attributes to random values |
| 116 | func (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 |
| 161 | func (testDevFile *TestDevfile) createCompositeCommand() *schema.Command { |
no test coverage detected