Skip to content

Commit e182d4b

Browse files
CM-63882 - added supporting unit tests
1 parent 9ad47bc commit e182d4b

1 file changed

Lines changed: 16 additions & 0 deletions

File tree

tests/cli/commands/scan/test_scan_command.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,9 @@
11
import click
22
import pytest
33
import typer
4+
from typer.testing import CliRunner
45

6+
from cycode.cli.app import app
57
from cycode.cli.apps.scan.scan_command import scan_command_result_callback
68
from cycode.cli.consts import ISSUE_DETECTED_STATUS_CODE, NO_ISSUES_STATUS_CODE, SCAN_ERROR_STATUS_CODE
79

@@ -25,6 +27,20 @@ def _invoke_result_callback(ctx: click.Context) -> int:
2527
return exc_info.value.exit_code
2628

2729

30+
class TestScanCommand:
31+
def test_multiple_scan_types_rejected(self) -> None:
32+
result = CliRunner().invoke(app, ['scan', '-t', 'iac', '-t', 'sast', 'path', '.'])
33+
assert result.exit_code == 2
34+
assert '-t/--scan-type' in result.output
35+
assert 'iac' in result.output
36+
assert 'sast' in result.output
37+
38+
def test_single_scan_type_accepted(self) -> None:
39+
result = CliRunner().invoke(app, ['scan', '-t', 'iac', '--help'])
40+
assert result.exit_code == 0
41+
assert 'Error' not in result.output
42+
43+
2844
class TestScanCommandResultCallback:
2945
def test_no_issues_no_errors_exits_zero(self) -> None:
3046
assert _invoke_result_callback(_make_ctx()) == NO_ISSUES_STATUS_CODE

0 commit comments

Comments
 (0)