Skip to content

Add negative/error test cases #16

Open

Description

@jtdub

Problem

There are no tests for error paths:

  • Invalid or unknown platform names
  • Malformed configuration text
  • Missing required fields in requests
  • 404 responses for non-existent remediation/report/job IDs
  • Invalid regex patterns in search
  • Empty config lists for merge
  • Requesting results for an incomplete batch job

The error handling code in routers and services is completely untested.

Suggested Fix

Add test cases covering at least:

def test_compare_configs_invalid_platform(client):
    response = client.post("/api/v1/configs/compare", json={...})
    # assert appropriate status code

def test_get_report_not_found(client):
    response = client.get("/api/v1/reports/nonexistent-id/summary")
    assert response.status_code == 404

def test_search_invalid_regex(client):
    response = client.post("/api/v1/configs/search", json={
        "match_rules": {"regex": "[invalid"}
    })
    assert response.status_code == 400

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions