Skip to content

test(coverage): raise decision_api.lua and saas_client.lua coverage above 80% #30

@levleontiev

Description

@levleontiev

Context

After PR #28 (issue #25), the following modules remain below 80% non-generated coverage:

File Coverage
decision_api.lua ~58.87%
saas_client.lua ~78.88%

Goal

Add targeted unit tests to raise both files meaningfully above 80%.

decision_api.lua gaps (58.87%)

Key uncovered paths:

  • build_request_context body parsing branches (JSON body, body file fallback)
  • _resolve_ip_from_header multi-value/invalid header branches
  • access phase: shadow-mode path, cost_based rule path
  • _apply_llm_budget_rule branches
  • body_filter_response non-streaming reconciliation path
  • _get_header_hint_tokens edge cases

saas_client.lua gaps (~78.88%)

Key uncovered paths:

  • queue_event when transport is unavailable
  • Retry/backoff logic branches
  • flush with empty queue
  • HTTP error response handling

Acceptance criteria

  • decision_api.lua coverage > 75% (from 58.87%)
  • saas_client.lua coverage > 85% (from 78.88%)
  • All existing + new tests pass (busted spec/unit/)
  • lua-quality CI green

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions