Testing¶
YAAMon has three layers of automated tests, all runnable via make.
Unit tests¶
Run inside a Docker container (Go not required on the host). Cover:
- Database operations (
internal/db/) - Authentication logic (
internal/auth/) - HTTP handlers (
internal/server/) — usinghttptest.NewRecorderand a real in-memory SQLite DB - Configuration loading (
internal/config/) - Backup/restore (
internal/backup/) - State management (
internal/state/)
Handler tests use real database instances (via t.TempDir()) rather than mocks, so SQL, migrations, and business logic are all exercised together.
go test ./internal/db/... # database tests
go test ./internal/server/... # handler tests
go test ./... # all packages
go test -run TestHandleAPI... # specific test
make coverage # HTML coverage report
Integration tests¶
Starts a real YAAMon Docker container (SUT), then runs Go tests in integration/ against it over HTTP. Tests exercise:
- First-run setup flow
- Login / logout
- Node creation and AMI connection
- Backup and restore
- Proxy auth header handling
- PUID/PGID entrypoint behaviour
make test-puid # verify uid/gid entrypoint handling in isolation
make test-deb # build snapshot .deb, install on Ubuntu 22.04, run integration tests
End-to-end tests (Playwright)¶
Full browser-based tests using Playwright in the e2e/ directory. Cover:
- Login and navigation
- Dashboard live updates
- Favorite management (add, reorder, connect)
- Admin user management
- Profile editing
- Theme switching
Pre-commit checks¶
Runs:
1. Whitespace check — trailing whitespace in staged files
2. go mod tidy verification — ensures go.mod and go.sum are up to date
Install as a git hook:
Test coverage¶
Generates an HTML coverage report for all packages and opens it in the browser.