mirror of
https://github.com/coder/coder.git
synced 2026-10-16 14:48:56 +08:00
`TestNotificationTemplates_Golden` built a coderd server, a second database and a mock SMTP server for each of its 86 template and method cases. The rendered output only depends on the recipient row and the appearance settings, so the test now builds one database, one recipient, one manager and one mock SMTP and webhook server for the whole run, and gives an isolated pipeline only to the two templates that render a different recipient or appearance (`TemplateUserRequestedOneTimePasscode`, `TemplateWorkspaceDeleted_CustomAppearance`). Deliveries are serialized per method because the mock SMTP backend records a single message. Test names, the `-update` flag and `make gen/golden-files` are unchanged, and the golden files are byte-identical. ## Before / After Local, `go test -count=1 -tags=testsmallbatch -parallel=8`, Postgres on localhost: | Measurement | Before | After | |---|---|---| | `TestNotificationTemplates_Golden` (`ok` line for `-run`) | 5.09s | 1.33s | | `coderd/notifications` package | 6.55s | 2.84s | | Sum of the 86 leaf subtest durations (slot time) | 38.4s | 8.3s | ## Validation - `go test -count=1 -tags=testsmallbatch -parallel=8 ./coderd/notifications/ -run '^TestNotificationTemplates_Golden$'` and the whole package pass - `TZ=UTC go test ./coderd/notifications -run="Test.*Golden$" -update` leaves `git status --porcelain coderd/notifications/testdata` empty - `go test -race -count=2 -shuffle=on -run '^TestNotificationTemplates_Golden$' ./coderd/notifications/` passes - `golangci-lint run ./coderd/notifications/...` reports 0 issues Part of the test-suite speedup series (see #29457); independent of the other PRs. ## Remote validation Remote run on a dogfood workspace (separate compute), chat https://dogfood.cdr.dev/agents/5bbe73d0-866a-4841-9cc3-c5e5b4d97e44, tested head `e44b489be9e` against base `9d973372774` on the same machine: `coderd/notifications` 7.53s to 2.92s; `-race -count=3 -shuffle=on -run '^TestNotificationTemplates_Golden$'`: pass; `TZ=UTC go test ./coderd/notifications -run="Test.*Golden$" -update` followed by `git status --porcelain coderd/notifications/testdata`: empty. Endorsed verdict: PASS. > Xum (an AI agent) authored this PR on behalf of @ibetitsmike.