@@ -203,6 +203,44 @@ func Test_statusValidator_Validate(t *testing.T) {
203
203
},
204
204
}).Detail (),
205
205
},
206
+ "returns error when there is a failed job with failure state" : {
207
+ selfJobName : "self-job" ,
208
+ client : & mock.Client {
209
+ GetCombinedStatusFunc : func (ctx context.Context , owner , repo , ref string , opts * github.ListOptions ) (* github.CombinedStatus , * github.Response , error ) {
210
+ return & github.CombinedStatus {
211
+ Statuses : []* github.RepoStatus {
212
+ {
213
+ Context : stringPtr ("job-01" ),
214
+ State : stringPtr (successState ),
215
+ },
216
+ {
217
+ Context : stringPtr ("job-02" ),
218
+ State : stringPtr (failureState ),
219
+ },
220
+ {
221
+ Context : stringPtr ("self-job" ),
222
+ State : stringPtr (pendingState ),
223
+ },
224
+ },
225
+ }, nil , nil
226
+ },
227
+ ListCheckRunsForRefFunc : func (ctx context.Context , owner , repo , ref string , opts * github.ListCheckRunsOptions ) (* github.ListCheckRunsResults , * github.Response , error ) {
228
+ return & github.ListCheckRunsResults {}, nil , nil
229
+ },
230
+ },
231
+ wantErr : true ,
232
+ wantErrStr : (& status {
233
+ totalJobs : []string {
234
+ "job-01" , "job-02" ,
235
+ },
236
+ completeJobs : []string {
237
+ "job-01" ,
238
+ },
239
+ errJobs : []string {
240
+ "job-02" ,
241
+ },
242
+ }).Detail (),
243
+ },
206
244
"returns failed status and nil when successful job count is less than total" : {
207
245
selfJobName : "self-job" ,
208
246
client : & mock.Client {
@@ -314,6 +352,40 @@ func Test_statusValidator_Validate(t *testing.T) {
314
352
errJobs : []string {},
315
353
},
316
354
},
355
+ "returns succeeded status and nil when only an ignored job is failing, with failure state" : {
356
+ selfJobName : "self-job" ,
357
+ ignoredJobs : []string {"job-02" , "job-03" },
358
+ client : & mock.Client {
359
+ GetCombinedStatusFunc : func (ctx context.Context , owner , repo , ref string , opts * github.ListOptions ) (* github.CombinedStatus , * github.Response , error ) {
360
+ return & github.CombinedStatus {
361
+ Statuses : []* github.RepoStatus {
362
+ {
363
+ Context : stringPtr ("job-01" ),
364
+ State : stringPtr (successState ),
365
+ },
366
+ {
367
+ Context : stringPtr ("job-02" ),
368
+ State : stringPtr (failureState ),
369
+ },
370
+ {
371
+ Context : stringPtr ("self-job" ),
372
+ State : stringPtr (pendingState ),
373
+ },
374
+ },
375
+ }, nil , nil
376
+ },
377
+ ListCheckRunsForRefFunc : func (ctx context.Context , owner , repo , ref string , opts * github.ListCheckRunsOptions ) (* github.ListCheckRunsResults , * github.Response , error ) {
378
+ return & github.ListCheckRunsResults {}, nil , nil
379
+ },
380
+ },
381
+ wantErr : false ,
382
+ wantStatus : & status {
383
+ succeeded : true ,
384
+ totalJobs : []string {"job-01" },
385
+ completeJobs : []string {"job-01" },
386
+ errJobs : []string {},
387
+ },
388
+ },
317
389
}
318
390
for name , tt := range tests {
319
391
t .Run (name , func (t * testing.T ) {
0 commit comments