Adds docs/testing.md as the authoritative testing map (consolidated from docs/contributing.md §8, now shrunk to a pointer), and a generated docs/endpoint-index.md via scripts/generate-endpoint-index.py (hooked into scripts/update-openapi.sh). Updates docs/README.md's reading order and removes the "still to come" placeholder. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
3.3 KiB
Testing map
Purpose: authoritative map of what each test project/suite covers and how to run it. Read this
before adding tests, not just docs/contributing.md §8 (which now just points here).
Test projects
| Project | Covers | Notes |
|---|---|---|
ErsatzTV.Tests |
API controllers + MediatR handlers | In-memory SQLite fixture: a shared SqliteConnection("Data Source=:memory:;Foreign Keys=False") kept open + EnsureCreatedAsync() (not full migration replay) + PRAGMA foreign_keys=OFF, then seed; a tiny IDbContextFactory wraps new TvContext(...). 828 tests currently. |
ErsatzTV.Core.Tests |
Domain logic, scheduling, IPTV/XMLTV generation | References ErsatzTV.Application directly — there is no separate Application.Tests project. 493 tests + 1 skipped. |
ErsatzTV.Architecture.Tests |
Layering rules via NetArchTest.eNhancedEdition | Core↛Infra/App/EF; FFmpeg↛all; App↛concrete providers. 5 tests. See docs/contributing.md §1. |
ErsatzTV.FFmpeg.Tests |
FFmpeg command construction | Build a pipeline, assert the exact rendered arg string (PipelineBuilderBaseTests.cs). |
web/ (vitest) |
React SPA unit tests | 330 tests; run alongside typecheck + build (see below). |
Golden-file nets
Two golden-file suites guard the Jellyfin-facing output formats:
- M3U:
ErsatzTV.Core.Tests/Iptv/ChannelPlaylistGoldenTests.cs(ersatztv#11) - XMLTV:
ChannelGuideGoldenTests(ersatztv#28)
Both locate their golden files via [CallerFilePath]. A missing golden is a hard fail, not a
skip. Regenerate via ETV_UPDATE_GOLDENS=1 dotnet test ....
Never set ETV_UPDATE_GOLDENS in CI or from an agent. A golden diff during normal test runs
means the code broke the output format — regenerating to make the diff go away hides the bug
instead of fixing it. Only a human who has confirmed the format change is intentional should
regenerate.
Timezone independence
The suite is timezone-independent (ersatztv#24). When constructing test PlayoutItems, always
set a real Start (e.g. startState.CurrentTime.UtcDateTime) — never rely on the default
DateTime.MinValue, which underflows DateTimeOffset.MinValue once a non-UTC local offset is
applied (StartOffset calls ToLocalTime()). CI runs in UTC; local runs may not.
Running tests
Full .NET gate:
dotnet build ErsatzTV.sln
TZ=UTC dotnet test
CI adds --blame-hang-timeout 2m to catch hangs.
Fast subsets:
# single project
dotnet test ErsatzTV.Tests
# filtered
dotnet test ErsatzTV.Core.Tests --filter FullyQualifiedName~ChannelPlaylistGoldenTests
Web (web/):
npm test # vitest
npm run typecheck # tsc -b --pretty false
npm run lint # eslint .
npm run build # tsc -b && vite build
Per-PR verification gate
Before opening a PR: build the solution, run both .NET test projects (plus
ErsatzTV.Architecture.Tests and ErsatzTV.FFmpeg.Tests if touched), and run the web test/lint/
typecheck/build steps above. All must be green. A golden-file diff or an architecture-test
failure is a hard stop — fix the code, don't regenerate/relax the test.
See also
docs/ci-cd.md— CI pipeline (test → migrations → build), versioning, dependency management.docs/contributing.md§1 — layering rules enforced byErsatzTV.Architecture.Tests.docs/contributing.md§8 — short pointer back to this doc.