test: reduce number of coderdtest instances (#23463)

Consolidates coderdtest invocations in 7 tests to reduce 23 instances to 7 across:
- `TestGetUser` (3 → 1) — read-only user lookups
- `TestUserTerminalFont` (3 → 1) — each creates own user via
CreateAnotherUser
- `TestUserTaskNotificationAlertDismissed` (3 → 1) — each creates own
user
- `TestUserLogin` (3 → 1) — each creates/deletes own user
- `TestExpMcpConfigureClaudeCode` (5 → 1) — writes to isolated temp dirs
- `TestOAuth2RegistrationTokenSecurity` (3 → 1) — independent
registrations
- `TestOAuth2SpecificErrorScenarios` (3 → 1) — independent error
scenarios

> 🤖 This PR was created with the help of Coder Agents, and has been
reviewed by my human. 🧑‍💻
This commit is contained in:
Cian Johnston
2026-03-25 09:53:06 +00:00
committed by GitHub
parent 72976b4749
commit 46edaf2112
5 changed files with 36 additions and 55 deletions
+5 -6
View File
@@ -104,11 +104,14 @@ func TestOAuth2ClientIsolation(t *testing.T) {
func TestOAuth2RegistrationTokenSecurity(t *testing.T) {
t.Parallel()
// Single instance shared across all sub-tests. Each registers
// independent OAuth2 apps with unique client names.
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
t.Run("InvalidTokenFormats", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
ctx := t.Context()
// Register a client to use for testing
@@ -145,8 +148,6 @@ func TestOAuth2RegistrationTokenSecurity(t *testing.T) {
t.Run("TokenNotReusableAcrossClients", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
ctx := t.Context()
// Register first client
@@ -179,8 +180,6 @@ func TestOAuth2RegistrationTokenSecurity(t *testing.T) {
t.Run("TokenNotExposedInGETResponse", func(t *testing.T) {
t.Parallel()
client := coderdtest.New(t, nil)
_ = coderdtest.CreateFirstUser(t, client)
ctx := t.Context()
// Register a client