()
| 157 | } |
| 158 | |
| 159 | func (j *Job) Run() error { |
| 160 | if j.Description == "" { |
| 161 | return ErrEmptyDescription |
| 162 | } |
| 163 | |
| 164 | // validate all steps in the job, making sure parameters are set/validated etc. |
| 165 | err := j.Validate() |
| 166 | if err != nil { |
| 167 | return err // nolint:wrapcheck // don't wrap error, wouldn't provide any more context than the error itself |
| 168 | } |
| 169 | |
| 170 | for _, wrapper := range j.Steps { |
| 171 | err := wrapper.Step.Prevalidate() |
| 172 | if err != nil { |
| 173 | return err //nolint:wrapcheck // don't wrap error, wouldn't provide any more context than the error itself |
| 174 | } |
| 175 | } |
| 176 | |
| 177 | for _, wrapper := range j.Steps { |
| 178 | j.responseDivider(wrapper) |
| 179 | err := wrapper.Step.Run() |
| 180 | if wrapper.Opts.ExpectError && err == nil { |
| 181 | return fmt.Errorf("expected error from step %s but got nil: %w", reflect.TypeOf(wrapper.Step).Elem().Name(), ErrNilError) |
| 182 | } else if !wrapper.Opts.ExpectError && err != nil { |
| 183 | return fmt.Errorf("did not expect error from step %s but got error: %w", reflect.TypeOf(wrapper.Step).Elem().Name(), err) |
| 184 | } |
| 185 | } |
| 186 | |
| 187 | return nil |
| 188 | } |
| 189 | |
| 190 | func (j *Job) Validate() error { |
| 191 | // ensure that there are no background steps left after running |
nothing calls this directly
no test coverage detected