Files
coder/coderd
Michael Suchacz f34aaeb017 test(coderd): share one server across the chat child archive tests (#30956)
Merges `TestPatchChatArchiveChildRejected`,
`TestPatchChatUnarchiveChildRejected`, and
`TestPatchChatArchiveRootRollsBackWhenChildCannotArchive` in
`coderd/exp_chats_chatstate_test.go` into `TestPatchChatChildArchive`.
Each old test started its own coderd server and built the same root and
child family. The new subtests share one server and a `createFamily`
helper that takes the child statuses, and each subtest still builds its
own family. The file starts 11 coderd servers instead of 13.

**Why it is safe:** each subtest makes the same requests and the same
status and archive-state assertions as the test it replaces. With the
old tests compiled back in through `go test -overlay`, both production
mutants failed the old tests that guarded the line and the subtests that
replace them:

| Mutant | Failed, old and new |
|---|---|
| a child archive or unarchive returns 409 instead of 400 |
`ArchiveChildRejected`, `UnarchiveChildRejected` |
| the family cascade ignores a child's `SetArchived` error |
`RootArchiveRollsBackWhenChildCannotArchive` |

**Review focus:** the subtests share a server, user, and model config.
Each one builds its own root and children and checks only those rows,
and `withChatWorkerDisabled` stays on.

**Timing** (`-count=1 -v -p 4 -parallel 4`, median of 5 paired runs on a
shared host): the three old tests took 1.4 s summed. The new test takes
0.5 s.

**Validation:**
- `go test ./coderd -run '^TestPatchChatChildArchive$' -count=10`: pass
- the same run with `-race -count=3`: pass
- `go vet ./coderd` and `golangci-lint run ./coderd/...`: clean; the
pre-commit hook passed

**Stack:** these two PRs share coderd servers across the copy-pasted
chatstate endpoint tests.

1. #30941: queue and invalid-state tables
2. #30956 (this PR): child archive tests on one server

> Xum, an AI agent, opened this PR for @ibetitsmike and wrote this
description.
2026-10-26 15:01:03 +00:00
..