Skip to content

Commit dee7f26

Browse files
committed
Add more tests
1 parent ae6f599 commit dee7f26

File tree

1 file changed

+20
-7
lines changed

1 file changed

+20
-7
lines changed

test/unit/test_findings_sync.py

Lines changed: 20 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,10 @@
3636

3737
CMD = "sonar-findings-sync.py"
3838

39-
PLAT_OPTS = f"{tutil.SQS_OPTS} -U {os.getenv('SONAR_HOST_URL_TEST')} -T {os.getenv('SONAR_TOKEN_SYNC_USER')}"
39+
TEST_URL = os.getenv('SONAR_HOST_URL_TEST')
40+
TEST_TOKEN = os.getenv('SONAR_TOKEN_SYNC_USER')
41+
PLAT_OPTS = f"{tutil.SQS_OPTS} --{opt.URL_TARGET} {TEST_URL} --{opt.TOKEN_TARGET} {TEST_TOKEN}"
42+
TEST_OPTS = f"--{opt.URL} {TEST_URL} --{opt.TOKEN} {TEST_TOKEN} --{opt.KEY_REGEXP} TESTSYNC"
4043
SC_PLAT_OPTS = f"{tutil.SQS_OPTS} -U https://sonarcloud.io -T {os.getenv('SONAR_TOKEN_SONARCLOUD')} -O okorach"
4144
SYNC_OPTS = f"-{opt.KEY_REGEXP_SHORT} {tutil.LIVE_PROJECT} -K TESTSYNC"
4245

@@ -46,19 +49,29 @@ def test_sync_help() -> None:
4649
assert tutil.run_cmd(findings_sync.main, f"{CMD} -h") == e.ARGS_ERROR
4750

4851

49-
def test_sync_proj(json_file: Generator[str]) -> None:
50-
"""test_sync_proj"""
52+
def test_sync_2_proj_all_branches(json_file: Generator[str]) -> None:
53+
"""test_sync_2_proj"""
5154
assert tutil.run_cmd(findings_sync.main, f"{CMD} {PLAT_OPTS} {SYNC_OPTS} -{opt.REPORT_FILE_SHORT} {json_file}") == e.OK
5255

56+
def test_sync_same_proj_all_branches(json_file: Generator[str]) -> None:
57+
"""test_sync_same_proj_all_branches"""
58+
# Project sync across all branches of a given project
59+
assert tutil.run_cmd(findings_sync.main, f"{CMD} {TEST_OPTS} --{opt.REPORT_FILE} {json_file}") == e.OK
5360

54-
def test_sync_branch(json_file: Generator[str]) -> None:
55-
"""test_sync_branch"""
61+
62+
def test_sync_same_proj_2_branches(json_file: Generator[str]) -> None:
63+
"""test_sync_same_proj_2_branches"""
64+
assert tutil.run_cmd(findings_sync.main, f"{CMD} {TEST_OPTS} --{opt.BRANCH_REGEXP} main -B develop --{opt.REPORT_FILE} {json_file}") == e.OK
65+
66+
67+
def test_sync_2_proj_branches(json_file: Generator[str]) -> None:
68+
"""test_sync_2_proj_branches"""
5669
code = e.UNSUPPORTED_OPERATION if tutil.SQ.edition() == c.CE else e.OK
57-
assert tutil.run_cmd(findings_sync.main, f"{CMD} {PLAT_OPTS} {SYNC_OPTS} -b master -B main -{opt.REPORT_FILE_SHORT} {json_file}") == code
70+
assert tutil.run_cmd(findings_sync.main, f"{CMD} {PLAT_OPTS} {SYNC_OPTS} --{opt.BRANCH_REGEXP} master -B main -{opt.REPORT_FILE_SHORT} {json_file}") == code
5871
if tutil.SQ.edition() == c.CE:
5972
assert tutil.run_cmd(findings_sync.main, f"{CMD} {PLAT_OPTS} {SYNC_OPTS} -B main -{opt.REPORT_FILE_SHORT} {json_file}") == e.OK
6073

6174

6275
def test_sync_scloud(json_file: Generator[str]) -> None:
6376
"""test_sync_scloud"""
64-
assert tutil.run_cmd(findings_sync.main, f"{CMD} {SC_PLAT_OPTS} {SYNC_OPTS} --threads 16 -{opt.REPORT_FILE_SHORT} {json_file}") == e.OK
77+
assert tutil.run_cmd(findings_sync.main, f"{CMD} {SC_PLAT_OPTS} {SYNC_OPTS} --{opt.NBR_THREADS} 16 -{opt.REPORT_FILE_SHORT} {json_file}") == e.OK

0 commit comments

Comments
 (0)