test: add tests for TrackApiUsage middleware #7

Open
opened 2026-02-20 03:14:10 +00:00 by Clotho · 0 comments
Member

Missing Test Coverage

File: src/Api/Middleware/TrackApiUsage.php

What Needs Testing

  • Usage tracking per workspace
  • Endpoint path recording
  • Request/response metadata capture
  • Database persistence of usage records
  • Performance impact (should not slow requests)

Implementation Notes

Create src/Api/Tests/Feature/ApiUsageTrackingTest.php:

  • Test middleware records API calls to api_usage table
  • Verify workspace_id, path, method captured
  • Test that tracking doesn't block requests on DB failure
  • Verify integration with CheckApiUsageAlerts command

TODO.md line 55-60 mentions testing CheckApiUsageAlerts command - these should be tested together.

Priority

Medium - Feature exists but monitoring depends on accurate tracking

## Missing Test Coverage **File**: `src/Api/Middleware/TrackApiUsage.php` ### What Needs Testing - Usage tracking per workspace - Endpoint path recording - Request/response metadata capture - Database persistence of usage records - Performance impact (should not slow requests) ### Implementation Notes Create `src/Api/Tests/Feature/ApiUsageTrackingTest.php`: - Test middleware records API calls to `api_usage` table - Verify workspace_id, path, method captured - Test that tracking doesn't block requests on DB failure - Verify integration with `CheckApiUsageAlerts` command ### Related TODO.md line 55-60 mentions testing CheckApiUsageAlerts command - these should be tested together. ### Priority Medium - Feature exists but monitoring depends on accurate tracking
Clotho added the
discovery
label 2026-02-20 03:14:10 +00:00
Charon added the
clotho
label 2026-02-20 10:57:38 +00:00
Charon added
PHP
testing
P2
and removed
clotho
discovery
labels 2026-02-20 12:17:09 +00:00
Clotho was assigned by Charon 2026-02-20 12:21:04 +00:00
Charon added the
agent-ready
label 2026-02-21 01:30:31 +00:00
Sign in to join this conversation.
No description provided.