|
5 | 5 |
|
6 | 6 | import pytest |
7 | 7 |
|
| 8 | +from bcbench.collection.collect_gh import screen_gh_candidate |
8 | 9 | from bcbench.collection.gh_client import GHClient |
9 | 10 | from bcbench.collection.patch_utils import extract_file_paths_from_patch, find_project_paths_from_diff, separate_patches |
10 | 11 | from bcbench.exceptions import CollectionError |
@@ -210,6 +211,38 @@ def test_get_file_content_success(self): |
210 | 211 | assert "codeunit 12345" in result |
211 | 212 |
|
212 | 213 |
|
| 214 | +class TestScreenGHCandidate: |
| 215 | + def test_returns_failed_result_when_test_patch_has_no_testable_functions(self): |
| 216 | + diff = """diff --git a/App/Apps/W1/Foo/app/Foo.Codeunit.al b/App/Apps/W1/Foo/app/Foo.Codeunit.al |
| 217 | +--- a/App/Apps/W1/Foo/app/Foo.Codeunit.al |
| 218 | ++++ b/App/Apps/W1/Foo/app/Foo.Codeunit.al |
| 219 | +@@ -1,3 +1,4 @@ |
| 220 | ++// Fix code |
| 221 | + procedure Main() |
| 222 | + begin |
| 223 | + end; |
| 224 | +diff --git a/App/Apps/W1/Foo/test/FooTests.Codeunit.al b/App/Apps/W1/Foo/test/FooTests.Codeunit.al |
| 225 | +--- a/App/Apps/W1/Foo/test/FooTests.Codeunit.al |
| 226 | ++++ b/App/Apps/W1/Foo/test/FooTests.Codeunit.al |
| 227 | +@@ -1,3 +1,4 @@ |
| 228 | ++// Not a test procedure |
| 229 | + procedure Helper() |
| 230 | + begin |
| 231 | + end; |
| 232 | +""" |
| 233 | + |
| 234 | + with patch("bcbench.collection.collect_gh.GHClient") as mock_client_class: |
| 235 | + mock_client = mock_client_class.return_value |
| 236 | + mock_client.get_pr_info.return_value = {"mergeCommit": {"oid": "abc123"}} |
| 237 | + mock_client.get_pr_diff.return_value = diff |
| 238 | + mock_client.get_file_content.return_value = 'codeunit 12345 "Foo Tests"' |
| 239 | + |
| 240 | + result = screen_gh_candidate(12345) |
| 241 | + |
| 242 | + assert not result.passed |
| 243 | + assert result.reason == "No testable functions found in test patch" |
| 244 | + |
| 245 | + |
213 | 246 | class TestExtractFilePathsFromPatch: |
214 | 247 | def test_extracts_single_file_path(self): |
215 | 248 | patch = """diff --git a/App/Code.al b/App/Code.al |
|
0 commit comments