Skip to content

[Endpoints] Case result submission + auto-upsert #301

Description

@bg-playground

Add per-test-case result endpoints. Auto-upserts new test cases when external_id is supplied but test_case_id is not — letting frameworks "discover" tests in BGSTM without pre-registration.

Parent: #291
Depends on: router skeleton sub

Endpoints

  • POST /api/v1/external-results/case
  • PATCH /api/v1/external-results/case/{id}
  • GET /api/v1/external-results/case/{id}

Auto-upsert rules

  • test_case_id supplied + exists: link to it
  • test_case_id supplied + missing: 404
  • Only external_id supplied: lookup by (project_id, external_id). Found → link. Not found → create with auto_registered=true
  • Neither supplied: 422

Traceability auto-link

If requirement_ids: [...] provided, write idempotent entries into the existing traceability table.

Status transition rules

  • started → any
  • passed/failed/skipped → only flaky (re-classification)
  • aborted → terminal
  • Violations return 409

Acceptance criteria

  • All three endpoints work behind runner token auth
  • FK enforced for known test_case_id
  • Auto-upsert path creates rows with auto_registered=true
  • requirement_ids triggers idempotent inserts into traceability
  • Status transition rules enforced + tested
  • Migration adds external_case_results table
  • Integration tests cover 4 upsert scenarios + 3 transition scenarios

Out of scope

  • Artifacts (separate sub)
  • Audit log (separate sub)

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