Files
coder/coderd
Michael Suchacz 83cdc8e346 test(coderd): table the chatstate queue and invalid-state endpoint tests (#30941)
Replaces nine copy-pasted endpoint tests in
`coderd/exp_chats_chatstate_test.go` with two table tests that each
share one coderd server. `TestChatQueueEndpointErrors` turns the four
queue delete and promote tests into rows.
`TestInvalidChatStateEndpoints` turns the two shared invalid-state
response tests into rows and holds the three reconcile cases as
subtests. Every old case stays a parallel subtest with its own chat, and
the file starts 13 coderd servers instead of 20.

**Why it is safe:** each subtest sends the same request and makes the
same assertions as the test it replaces. With the old tests compiled
back in through `go test -overlay`, each of 10 production mutants failed
exactly the old test that guarded the line and the subtest that replaces
it:

| Mutant | Failed, old and new |
|---|---|
| queue delete or promote returns 409 for an unknown ID, or 404 for an
empty queue (4 mutants) | the matching `Missing` or `EmptyQueue` case |
| send or tool results skip `writeChatInvalidState` (2 mutants) | the
matching `ReturnsSharedResponse` case |
| reconcile changes its not-invalid message |
`ReconcileNotInvalidReturnsConflict` |
| reconcile returns the old chat, or drops the default `last_error` (2
mutants) | `ReconcileSucceeds` |
| the chat URL parameter maps a missing chat to 500 |
`ReconcileNotFound` |

**Review focus:** subtests now share a server, user, and model config.
Each subtest creates its own chat and reads only that chat, and
`withChatWorkerDisabled` stays on, so no worker moves a chat between
steps.

**Timing** (`-count=1 -v -p 4 -parallel 4`, median of 5 paired runs on a
shared host): the nine old tests took 3.8 s summed. The two new tests
take 0.9 s.

**Validation:**
- `go test ./coderd -run
'^(TestChatQueueEndpointErrors|TestInvalidChatStateEndpoints)$'
-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 (this PR): queue and invalid-state tables
2. #30956: child archive tests on one server

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