@@ -363,6 +363,59 @@ def test_try_failed(_):
363363 assert state .get_status () == 'failure'
364364
365365
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+
366419@unittest .mock .patch ('homu.pull_req_state.assert_authorized' ,
367420 side_effect = return_true )
368421def test_build (_ ):
@@ -403,7 +456,7 @@ def test_build(_):
403456
404457 assert result .changed is True
405458 assert state .try_ is False
406- assert state .get_status () == 'success '
459+ assert state .get_status () == 'completed '
407460
408461
409462@unittest .mock .patch ('homu.pull_req_state.assert_authorized' ,
@@ -427,7 +480,7 @@ def test_build_failed(_):
427480 }))
428481
429482 assert result .changed is True
430- assert state .try_ is True
483+ assert state .try_ is False
431484 assert state .get_status () == 'pending'
432485
433486 result = state .process_event (create_event ({
@@ -443,7 +496,7 @@ def test_build_failed(_):
443496 }))
444497
445498 assert result .changed is True
446- assert state .try_ is True
499+ assert state .try_ is False
447500 assert state .get_status () == 'failure'
448501
449502
0 commit comments