@@ -363,6 +363,59 @@ def test_try_failed(_):
363
363
assert state .get_status () == 'failure'
364
364
365
365
366
+ @unittest .mock .patch ('homu.pull_req_state.assert_authorized' ,
367
+ side_effect = return_true )
368
+ def test_try_reset_by_push (_ ):
369
+ """
370
+ Test that a pull request that has been tried, and new commits pushed, does
371
+ not show up as tried
372
+ """
373
+
374
+ state = new_state ()
375
+ result = state .process_event (create_event ({
376
+ 'eventType' : 'IssueComment' ,
377
+ 'author' : {
378
+ 'login' : 'bors' ,
379
+ },
380
+ 'body' : '''
381
+ :hourglass: Trying commit 065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe with merge 330c85d9270b32d7703ebefc337eb37ae959f741...
382
+ <!-- homu: {"type":"TryBuildStarted","head_sha":"065151f8b2c31d9e4ddd34aaf8d3263a997f5cfe","merge_sha":"330c85d9270b32d7703ebefc337eb37ae959f741"} -->
383
+ ''' , # noqa
384
+ 'publishedAt' : '1985-04-21T00:00:00Z' ,
385
+ }))
386
+
387
+ assert result .changed is True
388
+ assert state .try_ is True
389
+ assert state .get_status () == 'pending'
390
+
391
+ result = state .process_event (create_event ({
392
+ 'eventType' : 'IssueComment' ,
393
+ 'author' : {
394
+ 'login' : 'bors' ,
395
+ },
396
+ 'body' : '''
397
+ :sunny: Try build successful - [checks-travis](https://travis-ci.com/rust-lang/rust/builds/115542062) Build commit: 330c85d9270b32d7703ebefc337eb37ae959f741
398
+ <!-- homu: {"type":"TryBuildCompleted","builders":{"checks-travis":"https://travis-ci.com/rust-lang/rust/builds/115542062"},"merge_sha":"330c85d9270b32d7703ebefc337eb37ae959f741"} -->
399
+ ''' , # noqa
400
+ 'publishedAt' : '1985-04-21T00:01:00Z' ,
401
+ }))
402
+
403
+ assert result .changed is True
404
+ assert state .try_ is True
405
+ assert state .get_status () == 'success'
406
+
407
+ result = state .process_event (create_event ({
408
+ 'eventType' : 'PullRequestCommit' ,
409
+ 'commit' : {
410
+ 'oid' : '012345' ,
411
+ }
412
+ }))
413
+
414
+ assert result .changed is True
415
+ assert state .try_ is False
416
+ assert state .get_status () == ''
417
+
418
+
366
419
@unittest .mock .patch ('homu.pull_req_state.assert_authorized' ,
367
420
side_effect = return_true )
368
421
def test_build (_ ):
@@ -403,7 +456,7 @@ def test_build(_):
403
456
404
457
assert result .changed is True
405
458
assert state .try_ is False
406
- assert state .get_status () == 'success '
459
+ assert state .get_status () == 'completed '
407
460
408
461
409
462
@unittest .mock .patch ('homu.pull_req_state.assert_authorized' ,
@@ -427,7 +480,7 @@ def test_build_failed(_):
427
480
}))
428
481
429
482
assert result .changed is True
430
- assert state .try_ is True
483
+ assert state .try_ is False
431
484
assert state .get_status () == 'pending'
432
485
433
486
result = state .process_event (create_event ({
@@ -443,7 +496,7 @@ def test_build_failed(_):
443
496
}))
444
497
445
498
assert result .changed is True
446
- assert state .try_ is True
499
+ assert state .try_ is False
447
500
assert state .get_status () == 'failure'
448
501
449
502
0 commit comments