Testing
:::info Source
Sourced from services/media-service/TESTING_STRATEGY.md in the documentation repo.
:::
1. Coverage Targets
Domain 95% / 98% / 80% mutation. Integration 80%.
2. Unit Tests
- MediaAsset state machine.
- SHA-256 dedup.
- Caption format parsing (VTT, SRT).
- Variant profile resolver.
- AI provenance invariants.
3. Integration (Testcontainers)
- Postgres + MinIO + ClamAV + mock ai-gateway.
- Flow: upload URL → S3 upload → scan → transcode → ready.
- Quarantine path with malicious fixture.
- Caption generation E2E.
4. Contract Tests
- Pact with authoring, content, search.
- OpenAPI diff in CI.
5. E2E
- Author uploads video → ready → author inserts block → publish.
- AI-generated image → inserted → published bundle includes it.
6. Load
- 500 concurrent uploads (1 GB/s throughput).
- Transcode queue: 100 concurrent video jobs.
- Stream: 10k concurrent HLS viewers.
7. Security Tests
- EICAR AV test → quarantined.
- Path traversal in filename → sanitized.
- Cross-tenant asset access → 403.
- Signed URL after TTL → 403.
- Malicious content classifier tests (CSAM simulation fixtures → quarantine path).
8. AI Tests
- Image gen determinism (same prompt + seed → same output).
- STT accuracy eval on multi-accent corpus.
- Caption review workflow.
9. Offline Tests
- Bundle-embedded media decrypts + plays offline.
- Caption tracks available offline.
10. CI Gates
Unit + integration + security fixtures + OpenAPI + Pact + iso + mutation ≥ 80%.