mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
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:
@@ -356,11 +356,14 @@ func TestOAuth2ErrorHTTPHeaders(t *testing.T) {
|
||||
func TestOAuth2SpecificErrorScenarios(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
// Single instance shared across all sub-tests that need a
|
||||
// coderd server. Sub-tests that don't need one just ignore it.
|
||||
client := coderdtest.New(t, nil)
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
|
||||
t.Run("MissingRequiredFields", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, nil)
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
// Test completely empty request
|
||||
@@ -385,8 +388,6 @@ func TestOAuth2SpecificErrorScenarios(t *testing.T) {
|
||||
t.Run("UnsupportedFields", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, nil)
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
// Test with fields that might not be supported yet
|
||||
@@ -408,8 +409,6 @@ func TestOAuth2SpecificErrorScenarios(t *testing.T) {
|
||||
t.Run("SecurityBoundaryErrors", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
client := coderdtest.New(t, nil)
|
||||
_ = coderdtest.CreateFirstUser(t, client)
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
// Register a client first
|
||||
|
||||
Reference in New Issue
Block a user