2222from clusterfuzz ._internal .tests .test_libs import test_utils
2323from libs .issue_management import oss_fuzz_github
2424
25- REPO_NAME = 'sample/sample.git '
25+ REPO_NAME = 'sample/sample'
2626MAIN_REPO = f'https://github.com/{ REPO_NAME } '
27+ MAIN_REPO_SUFFIX = f'https://github.com/{ REPO_NAME } .git'
2728JOB1_ENVIRONMENT = f'MAIN_REPO = { MAIN_REPO } \n ' \
2829 'FILE_GITHUB_ISSUE = True'
2930
3233
3334JOB3_ENVIRONMENT = f'MAIN_REPO = { MAIN_REPO } \n '
3435
36+ JOB4_ENVIRONMENT = f'MAIN_REPO = { MAIN_REPO_SUFFIX } \n ' \
37+ 'FILE_GITHUB_ISSUE = True'
38+
3539GITHUB_REPO_ID = 100
3640GITHUB_ISSUE_NUM = 200
3741GITHUB_ACCESS_TOKEN = 'SECRET'
@@ -55,6 +59,10 @@ def setUp(self):
5559 name = 'job3' , environment_string = JOB3_ENVIRONMENT ,
5660 platform = 'linux' ).put ()
5761
62+ data_types .Job (
63+ name = 'job4' , environment_string = JOB4_ENVIRONMENT ,
64+ platform = 'linux' ).put ()
65+
5866 testcase_args1 = {
5967 'bug_information' : '300' ,
6068 }
@@ -77,6 +85,9 @@ def setUp(self):
7785 self .testcase4 = data_types .Testcase (job_type = 'job1' , ** testcase_args2 )
7886 self .testcase4 .put ()
7987
88+ self .testcase5 = data_types .Testcase (job_type = 'job4' , ** testcase_args1 )
89+ self .testcase5 .put ()
90+
8091 test_helpers .patch (self , [
8192 'clusterfuzz._internal.config.db_config.get_value' ,
8293 ])
@@ -90,15 +101,17 @@ def test_file_issue(self, mock_github):
90101 mock_github .Github ().get_repo ().create_issue .return_value = mock .MagicMock (
91102 number = GITHUB_ISSUE_NUM )
92103
93- oss_fuzz_github .file_issue (self .testcase1 )
94-
95- mock_github .Github .assert_called_with (GITHUB_ACCESS_TOKEN )
96- mock_github .Github ().get_repo .assert_called_with (REPO_NAME )
97- mock_github .Github ().get_repo ().create_issue .assert_called_once_with (
98- title = oss_fuzz_github .get_issue_title (self .testcase1 ),
99- body = oss_fuzz_github .get_issue_body (self .testcase1 ))
100- self .assertEqual (self .testcase1 .github_repo_id , GITHUB_REPO_ID )
101- self .assertEqual (self .testcase1 .github_issue_num , GITHUB_ISSUE_NUM )
104+ for testcase in [self .testcase1 , self .testcase5 ]:
105+ oss_fuzz_github .file_issue (testcase )
106+
107+ mock_github .Github .assert_called_with (GITHUB_ACCESS_TOKEN )
108+ mock_github .Github ().get_repo .assert_called_with (REPO_NAME )
109+ mock_github .Github ().get_repo ().create_issue .assert_called_once_with (
110+ title = oss_fuzz_github .get_issue_title (testcase ),
111+ body = oss_fuzz_github .get_issue_body (testcase ))
112+ self .assertEqual (testcase .github_repo_id , GITHUB_REPO_ID )
113+ self .assertEqual (testcase .github_issue_num , GITHUB_ISSUE_NUM )
114+ mock_github .reset_mock ()
102115
103116 @mock .patch ('libs.issue_management.oss_fuzz_github.github' )
104117 def test_not_file_issue (self , mock_github ):
0 commit comments