Skip to content

test : add unit tests for CLI argument parsing and run_scan edge cases #1227

Description

@tmdeveloper007

Summary of What Needs to be Done:
Expand testing/backend/unit/test_cli.py to cover argument parsing edge cases and error paths in run_scan that are not yet tested. Currently only 3 tests exist (plugin-not-found, successful-scan, help-menu).

Changes that Need to be Made:

  • Add to testing/backend/unit/test_cli.py
  • main() with no arguments should call print_help (current test only covers --help)
  • run_scan with an invalid output format should not crash
  • run_scan when target is "." should default to secret_scanner or code_analyzer
  • run_scan when DB fetch returns None (task disappeared) should return 1
  • run_scan with failed task (status=failed) should return 1
  • run_scan with output file saves the report to the correct path
  • Import the real functions from backend.secuscan.cli.
  • Use the same mock pattern already in test_cli.py (patch init_db, init_cache, init_plugins, etc.)

Impact that it would Provide:
The CLI is the user-facing entry point. An unhandled edge case (e.g. task record missing after completion) would cause a cryptic traceback instead of a clean exit code. Adding these tests ensures the CLI degrades gracefully in all failure scenarios covered.

Note: This task is being handled by tmdeveloper007 — please assign to that account when picking it up.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions