SetEventsValues randomly adds/modifies attributes of the supplied events
(events *schema.Events)
| 49 | |
| 50 | // SetEventsValues randomly adds/modifies attributes of the supplied events |
| 51 | func (devfile *TestDevfile) SetEventsValues(events *schema.Events) { |
| 52 | if GetRandomDecision(4, 1) { |
| 53 | numPreStart := GetRandomNumber(1, 5) |
| 54 | LogInfoMessage(fmt.Sprintf(" ....... add %d command(s) to PreStart event", numPreStart)) |
| 55 | for i := 0; i < numPreStart; i++ { |
| 56 | if GetRandomDecision(4, 1) { |
| 57 | events.PreStart = append(events.PreStart, devfile.AddCommand(schema.ApplyCommandType).Id) |
| 58 | } else { |
| 59 | compositeCommand := devfile.AddCommand(schema.CompositeCommandType) |
| 60 | devfile.SetCompositeCommandCommands(&compositeCommand, schema.ApplyCommandType) |
| 61 | events.PreStart = append(events.PreStart, compositeCommand.Id) |
| 62 | } |
| 63 | } |
| 64 | } |
| 65 | if GetRandomDecision(4, 1) { |
| 66 | numPostStart := GetRandomNumber(1, 5) |
| 67 | LogInfoMessage(fmt.Sprintf(" ....... add %d command(s) to PostStart event", numPostStart)) |
| 68 | for i := 0; i < numPostStart; i++ { |
| 69 | if GetRandomDecision(4, 1) { |
| 70 | events.PostStart = append(events.PostStart, devfile.AddCommand(schema.ExecCommandType).Id) |
| 71 | } else { |
| 72 | compositeCommand := devfile.AddCommand(schema.CompositeCommandType) |
| 73 | devfile.SetCompositeCommandCommands(&compositeCommand, schema.ExecCommandType) |
| 74 | events.PostStart = append(events.PostStart, compositeCommand.Id) |
| 75 | } |
| 76 | } |
| 77 | } |
| 78 | if GetRandomDecision(4, 1) { |
| 79 | numPreStop := GetRandomNumber(1, 5) |
| 80 | LogInfoMessage(fmt.Sprintf(" ....... add %d command(s) to PreStop event", numPreStop)) |
| 81 | for i := 0; i < numPreStop; i++ { |
| 82 | if GetRandomDecision(4, 1) { |
| 83 | events.PreStop = append(events.PreStop, devfile.AddCommand(schema.ExecCommandType).Id) |
| 84 | } else { |
| 85 | compositeCommand := devfile.AddCommand(schema.CompositeCommandType) |
| 86 | devfile.SetCompositeCommandCommands(&compositeCommand, schema.ExecCommandType) |
| 87 | events.PreStop = append(events.PreStop, compositeCommand.Id) |
| 88 | } |
| 89 | } |
| 90 | } |
| 91 | if GetRandomDecision(4, 1) { |
| 92 | numPostStop := GetRandomNumber(1, 5) |
| 93 | LogInfoMessage(fmt.Sprintf(" ....... add %d command(s) to PostStop event", numPostStop)) |
| 94 | for i := 0; i < numPostStop; i++ { |
| 95 | if GetRandomDecision(4, 1) { |
| 96 | events.PostStop = append(events.PostStop, devfile.AddCommand(schema.ApplyCommandType).Id) |
| 97 | } else { |
| 98 | compositeCommand := devfile.AddCommand(schema.CompositeCommandType) |
| 99 | devfile.SetCompositeCommandCommands(&compositeCommand, schema.ApplyCommandType) |
| 100 | events.PostStop = append(events.PostStop, compositeCommand.Id) |
| 101 | } |
| 102 | } |
| 103 | } |
| 104 | devfile.EventsUpdated(events) |
| 105 | } |
no test coverage detected