@@ -527,6 +527,10 @@ def test_event_range_without_a_payload_is_empty(self):
527527 self .assertEqual (main .get_messages_from_event_range (), [])
528528 mock_run .assert_not_called ()
529529
530+ def test_a_failing_git_log_yields_no_messages (self ):
531+ with patch ("main.subprocess.run" , return_value = MagicMock (returncode = 128 )):
532+ self .assertEqual (main .get_messages_from_head_ref ("main" ), [])
533+
530534 def test_get_messages_from_head_ref (self ):
531535 mock_result = MagicMock (returncode = 0 , stdout = "fix: first\n \x00 " )
532536 with patch ("main.subprocess.run" , return_value = mock_result ) as mock_run :
@@ -964,9 +968,24 @@ def test_reads_the_head_sha_from_the_event(self):
964968 finally :
965969 os .unlink (event_path )
966970
971+ def test_reads_the_base_sha_from_the_event (self ):
972+ with tempfile .NamedTemporaryFile ("w" , suffix = ".json" , delete = False ) as f :
973+ json .dump ({"pull_request" : {"base" : {"sha" : "base111" }}}, f )
974+ event_path = f .name
975+ try :
976+ with patch .dict (
977+ os .environ ,
978+ {"GITHUB_EVENT_NAME" : "pull_request" , "GITHUB_EVENT_PATH" : event_path },
979+ ):
980+ self .assertEqual (main .get_pr_base_sha (), "base111" )
981+ self .assertIsNone (main .get_pr_head_sha ())
982+ finally :
983+ os .unlink (event_path )
984+
967985 def test_not_a_pr_event_returns_none (self ):
968986 with patch .dict (os .environ , {"GITHUB_EVENT_NAME" : "push" }):
969987 self .assertIsNone (main .get_pr_head_sha ())
988+ self .assertIsNone (main .get_pr_base_sha ())
970989
971990 def test_missing_event_path_returns_none (self ):
972991 with patch .dict (os .environ , {"GITHUB_EVENT_NAME" : "pull_request" }):
0 commit comments