From d8ea897e32169b0512f8b3d37e61149625db8f73 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 18 Jun 2025 21:36:46 +0000 Subject: [PATCH 1/4] chore: remove unnecessary redelarations in for loops --- agent/agent.go | 2 +- agent/agent_test.go | 21 +++++++++---------- .../containers_internal_test.go | 4 ++-- agent/agentscripts/agentscripts.go | 3 +-- agent/agentssh/x11_internal_test.go | 2 +- agent/proto/compare_test.go | 2 +- agent/proto/resourcesmonitor/queue_test.go | 1 - .../resources_monitor_test.go | 2 +- apiversion/apiversion_test.go | 2 +- buildinfo/buildinfo_test.go | 2 +- cli/agent_internal_test.go | 2 +- cli/autoupdate_test.go | 2 +- cli/clitest/golden.go | 2 +- cli/cliui/agent_test.go | 6 +++--- cli/cliui/provisionerjob_test.go | 1 - cli/cliui/resources_internal_test.go | 2 +- cli/cliui/table_test.go | 2 +- cli/cliutil/levenshtein/levenshtein_test.go | 4 ++-- cli/cliutil/provisionerwarn_test.go | 2 +- cli/configssh_internal_test.go | 10 ++++----- cli/configssh_test.go | 2 +- cli/exp_errors_test.go | 2 +- cli/gitauth/askpass_test.go | 2 +- cli/notifications_test.go | 2 +- cli/open_internal_test.go | 4 ++-- cli/open_test.go | 6 ++---- cli/organizationroles.go | 2 +- cli/organizationsettings.go | 4 ++-- cli/portforward_internal_test.go | 2 +- cli/portforward_test.go | 2 +- cli/provisionerjobs_test.go | 2 +- cli/root_internal_test.go | 2 +- cli/schedule_internal_test.go | 2 +- cli/schedule_test.go | 1 - cli/server.go | 4 ++-- cli/server_internal_test.go | 10 ++++----- cli/server_test.go | 5 ++--- cli/ssh_test.go | 4 ++-- cli/start_test.go | 2 +- cli/templateedit_test.go | 4 ++-- cli/templatepull_test.go | 1 - cli/templatepush_test.go | 2 +- cli/util_internal_test.go | 4 ++-- cli/version_test.go | 2 +- cli/vpndaemon_windows_test.go | 2 +- coderd/agentapi/manifest_internal_test.go | 2 +- coderd/agentapi/resources_monitoring_test.go | 2 -- coderd/agentmetrics/labels_test.go | 1 - coderd/apikey/apikey_test.go | 2 +- coderd/audit_test.go | 2 +- coderd/authorize_test.go | 1 - .../lifecycle_executor_internal_test.go | 2 +- coderd/autobuild/lifecycle_executor_test.go | 2 +- coderd/autobuild/notify/notifier_test.go | 2 +- coderd/azureidentity/azureidentity_test.go | 2 +- coderd/coderd_internal_test.go | 1 - coderd/database/db2sdk/db2sdk_test.go | 3 +-- coderd/database/dbauthz/customroles_test.go | 3 +-- coderd/database/dbauthz/groupsauth_test.go | 2 +- coderd/database/dbauthz/setup_test.go | 2 +- coderd/database/dbmem/dbmem.go | 9 ++++---- coderd/database/dbmem/dbmem_test.go | 2 +- coderd/database/migrations/migrate_test.go | 1 - coderd/database/pubsub/pubsub_memory.go | 2 +- coderd/database/querier_test.go | 15 +++++++------ coderd/devtunnel/tunnel_test.go | 1 - coderd/externalauth/externalauth.go | 1 - .../externalauth_internal_test.go | 4 ++-- coderd/externalauth/externalauth_test.go | 2 +- coderd/healthcheck/health/model_test.go | 2 +- coderd/healthcheck/healthcheck_test.go | 2 +- coderd/healthcheck/provisioner_test.go | 2 +- .../workspaceproxy_internal_test.go | 4 ++-- coderd/healthcheck/workspaceproxy_test.go | 2 +- coderd/httpapi/cookie_test.go | 2 +- coderd/httpapi/json_test.go | 3 --- coderd/httpmw/authorize_test.go | 2 +- coderd/httpmw/cors_test.go | 2 +- coderd/httpmw/csrf_test.go | 2 +- coderd/httpmw/hsts_test.go | 2 +- .../httpmw/loggermw/logger_internal_test.go | 2 +- .../patternmatcher/routepatterns_test.go | 2 +- coderd/httpmw/realip_test.go | 16 ++++++-------- coderd/httpmw/recover_test.go | 1 - coderd/httpmw/workspaceparam_test.go | 2 +- coderd/idpsync/group.go | 5 ++--- coderd/idpsync/group_test.go | 7 +++---- coderd/idpsync/idpsync_test.go | 2 +- coderd/idpsync/role_test.go | 3 +-- coderd/inboxnotifications_internal_test.go | 1 - coderd/inboxnotifications_test.go | 4 ++-- coderd/insights_internal_test.go | 5 ++--- coderd/insights_test.go | 20 ++++++------------ coderd/jobreaper/detector_test.go | 1 - coderd/jwtutils/jwt_test.go | 3 +-- coderd/metricscache/metricscache_test.go | 2 +- coderd/notifications/dispatch/inbox_test.go | 2 +- coderd/notifications/notifications_test.go | 2 -- coderd/notifications/render/gotmpl_test.go | 2 +- coderd/oauth2_test.go | 8 +++---- coderd/pagination_internal_test.go | 2 +- coderd/prebuilds/preset_snapshot_test.go | 4 ++-- coderd/presets_test.go | 2 +- coderd/prometheusmetrics/aggregator_test.go | 1 - .../prometheusmetrics_internal_test.go | 1 - .../prometheusmetrics_test.go | 9 ++++---- coderd/promoauth/oauth2_test.go | 2 +- coderd/provisionerdserver/acquirer_test.go | 2 +- .../provisionerdserver_test.go | 8 +++---- coderd/provisionerjobs_internal_test.go | 2 +- coderd/rbac/authz.go | 2 +- coderd/rbac/authz_internal_test.go | 4 ++-- coderd/rbac/object_test.go | 2 +- coderd/rbac/regosql/compile_test.go | 2 +- coderd/rbac/regosql/sqltypes/equality_test.go | 2 +- coderd/rbac/regosql/sqltypes/member_test.go | 2 +- coderd/rbac/roles.go | 2 +- coderd/rbac/roles_internal_test.go | 2 +- coderd/rbac/roles_test.go | 10 ++++----- coderd/rbac/subject_test.go | 2 +- coderd/render/markdown_test.go | 1 - coderd/schedule/autostop_test.go | 3 +-- coderd/schedule/cron/cron_test.go | 2 +- coderd/searchquery/search_test.go | 8 +++---- coderd/tailnet_test.go | 2 +- coderd/telemetry/telemetry_test.go | 2 +- coderd/templateversions_test.go | 6 +++--- coderd/tracing/httpmw_test.go | 1 - coderd/updatecheck/updatecheck_test.go | 2 +- coderd/updatecheck_test.go | 1 - coderd/userauth_test.go | 2 +- coderd/userpassword/userpassword_test.go | 4 ++-- coderd/users_test.go | 6 +++--- coderd/util/maps/maps_test.go | 2 +- coderd/util/strings/strings_test.go | 2 +- coderd/util/xio/limitwriter_test.go | 2 +- coderd/webpush/webpush.go | 2 +- coderd/workspaceagents_test.go | 6 +++--- coderd/workspaceapps/apptest/apptest.go | 2 -- coderd/workspaceapps/appurl/appurl_test.go | 10 ++++----- coderd/workspaceapps/db_test.go | 1 - coderd/workspaceapps/request_test.go | 2 +- coderd/workspaceapps/stats_test.go | 2 +- coderd/workspaceapps/token_test.go | 1 - coderd/workspaceapps_test.go | 4 ++-- coderd/workspaces_test.go | 9 ++++---- coderd/workspacestats/activitybump_test.go | 4 ++-- codersdk/agentsdk/logs_test.go | 4 ++-- codersdk/client_internal_test.go | 3 +-- codersdk/deployment_internal_test.go | 1 - codersdk/deployment_test.go | 6 ++---- codersdk/healthsdk/healthsdk_test.go | 2 +- .../healthsdk/interfaces_internal_test.go | 2 +- codersdk/name_test.go | 12 +++++------ codersdk/pagination_test.go | 2 +- codersdk/richparameters_test.go | 2 +- codersdk/time_test.go | 6 +++--- .../workspacedisplaystatus_internal_test.go | 2 +- cryptorand/strings_test.go | 2 +- enterprise/audit/audit_test.go | 2 +- enterprise/audit/diff_internal_test.go | 2 +- enterprise/cli/start_test.go | 4 ++-- enterprise/coderd/authorize_test.go | 1 - enterprise/coderd/coderd_test.go | 3 +-- .../coderd/enidpsync/organizations_test.go | 2 +- .../coderd/httpmw/provisionerdaemon_test.go | 2 +- enterprise/coderd/insights_test.go | 4 ++-- enterprise/coderd/license/license_test.go | 1 - enterprise/coderd/prebuilds/claim_test.go | 2 +- .../coderd/prebuilds/membership_test.go | 2 +- .../coderd/prebuilds/metricscollector_test.go | 16 +++++++------- enterprise/coderd/prebuilds/reconcile_test.go | 2 +- enterprise/coderd/provisionerdaemons_test.go | 2 +- enterprise/coderd/provisionerkeys_test.go | 2 +- enterprise/coderd/proxyhealth/proxyhealth.go | 2 +- enterprise/coderd/roles_test.go | 2 +- enterprise/coderd/schedule/template_test.go | 2 -- enterprise/coderd/templates_test.go | 1 - enterprise/coderd/userauth_test.go | 2 +- enterprise/coderd/users_test.go | 2 +- .../coderd/workspaceproxy_internal_test.go | 2 +- enterprise/coderd/workspaces_test.go | 2 +- .../provisionerd/remoteprovisioners_test.go | 2 +- enterprise/replicasync/replicasync.go | 2 +- enterprise/wsproxy/wsproxy_test.go | 4 ++-- examples/examples_test.go | 2 +- helm/coder/tests/chart_test.go | 7 +++---- helm/provisioner/tests/chart_test.go | 8 +++---- provisioner/terraform/diagnostic_test.go | 1 - .../terraform/executor_internal_test.go | 1 - provisioner/terraform/parse_test.go | 2 +- provisioner/terraform/provision_test.go | 4 ++-- provisioner/terraform/resources_test.go | 11 +++++----- provisioner/terraform/tfparse/tfparse_test.go | 2 +- provisionersdk/provisionertags_test.go | 2 +- pty/ptytest/ptytest_test.go | 2 +- scaletest/agentconn/config_test.go | 1 - scaletest/createworkspaces/config_test.go | 2 -- scaletest/harness/strategies.go | 2 +- scaletest/harness/strategies_test.go | 1 - scaletest/placebo/config_test.go | 1 - scaletest/reconnectingpty/config_test.go | 1 - scaletest/workspacebuild/config_test.go | 1 - scripts/apitypings/main_test.go | 2 +- scripts/release/main_internal_test.go | 4 ++-- scripts/releasemigrations/main.go | 2 +- scripts/typegen/main.go | 2 +- site/site.go | 3 +-- site/site_test.go | 2 +- tailnet/configmaps_internal_test.go | 2 +- tailnet/convert_test.go | 2 +- tailnet/telemetry_internal_test.go | 2 +- vpn/tunnel_internal_test.go | 2 +- vpn/version_test.go | 4 ++-- 214 files changed, 296 insertions(+), 378 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 79f3feb21c50e..569b66d19fe29 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -547,7 +547,7 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26 // channel to synchronize the results and avoid both messy // mutex logic and overloading the API. for _, md := range manifest.Metadata { - md := md + // We send the result to the channel in the goroutine to avoid // sending the same result multiple times. So, we don't care about // the return values. diff --git a/agent/agent_test.go b/agent/agent_test.go index 55b1808784aa6..244fa7a899211 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -130,7 +130,7 @@ func TestAgent_Stats_SSH(t *testing.T) { t.Parallel() for _, port := range sshPorts { - port := port + t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Parallel() @@ -342,7 +342,7 @@ func TestAgent_SessionExec(t *testing.T) { t.Parallel() for _, port := range sshPorts { - port := port + t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Parallel() @@ -468,7 +468,7 @@ func TestAgent_SessionTTYShell(t *testing.T) { } for _, port := range sshPorts { - port := port + t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) { t.Parallel() @@ -611,7 +611,7 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) { @@ -688,7 +688,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) { //nolint:paralleltest // These tests need to swap the banner func. for _, port := range sshPorts { - port := port sshClient, err := conn.SSHClientOnPort(ctx, port) require.NoError(t, err) @@ -697,7 +696,7 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) { }) for i, test := range tests { - test := test + t.Run(fmt.Sprintf("(:%d)/%d", port, i), func(t *testing.T) { // Set new banner func and wait for the agent to call it to update the // banner. @@ -1210,7 +1209,7 @@ func TestAgent_CoderEnvVars(t *testing.T) { t.Parallel() for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} { - key := key + t.Run(key, func(t *testing.T) { t.Parallel() @@ -1233,7 +1232,7 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) { // For some reason this test produces a TTY locally and a non-TTY in CI // so we don't test for the absence of SSH_TTY. for _, key := range []string{"SSH_CONNECTION", "SSH_CLIENT"} { - key := key + t.Run(key, func(t *testing.T) { t.Parallel() @@ -1276,7 +1275,7 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.key, func(t *testing.T) { t.Parallel() @@ -1796,7 +1795,7 @@ func TestAgent_ReconnectingPTY(t *testing.T) { t.Setenv("LANG", "C") for _, backendType := range backends { - backendType := backendType + t.Run(backendType, func(t *testing.T) { if backendType == "Screen" { if runtime.GOOS != "linux" { @@ -2496,7 +2495,7 @@ func TestAgent_Dial(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/agent/agentcontainers/containers_internal_test.go b/agent/agentcontainers/containers_internal_test.go index eeb6a5d0374d1..85d5690eb5bf9 100644 --- a/agent/agentcontainers/containers_internal_test.go +++ b/agent/agentcontainers/containers_internal_test.go @@ -41,7 +41,7 @@ func TestWrapDockerExec(t *testing.T) { }, } for _, tt := range tests { - tt := tt // appease the linter even though this isn't needed anymore + // appease the linter even though this isn't needed anymore t.Run(tt.name, func(t *testing.T) { t.Parallel() actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...) @@ -151,7 +151,7 @@ func TestConvertDockerVolume(t *testing.T) { expectError: "invalid volume", }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() }) diff --git a/agent/agentscripts/agentscripts.go b/agent/agentscripts/agentscripts.go index 79606a80233b9..80c7b4e8c3517 100644 --- a/agent/agentscripts/agentscripts.go +++ b/agent/agentscripts/agentscripts.go @@ -177,7 +177,7 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S if script.Cron == "" { continue } - script := script + _, err := r.cron.AddFunc(script.Cron, func() { err := r.trackRun(r.cronCtx, script.WorkspaceAgentScript, ExecuteCronScripts) if err != nil { @@ -254,7 +254,6 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error { continue } - script := script eg.Go(func() error { err := r.trackRun(ctx, script.WorkspaceAgentScript, option) if err != nil { diff --git a/agent/agentssh/x11_internal_test.go b/agent/agentssh/x11_internal_test.go index fdc3c04668663..a8e553e911128 100644 --- a/agent/agentssh/x11_internal_test.go +++ b/agent/agentssh/x11_internal_test.go @@ -228,7 +228,7 @@ func Test_addXauthEntry(t *testing.T) { require.NoError(t, err) for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/agent/proto/compare_test.go b/agent/proto/compare_test.go index 3c5bdbf93a9e1..b545e9b1b76a3 100644 --- a/agent/proto/compare_test.go +++ b/agent/proto/compare_test.go @@ -67,7 +67,7 @@ func TestLabelsEqual(t *testing.T) { eq: false, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() require.Equal(t, tc.eq, proto.LabelsEqual(tc.a, tc.b)) diff --git a/agent/proto/resourcesmonitor/queue_test.go b/agent/proto/resourcesmonitor/queue_test.go index a3a8fbc0d0a3a..a35a2dd48eff0 100644 --- a/agent/proto/resourcesmonitor/queue_test.go +++ b/agent/proto/resourcesmonitor/queue_test.go @@ -65,7 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/agent/proto/resourcesmonitor/resources_monitor_test.go b/agent/proto/resourcesmonitor/resources_monitor_test.go index ddf3522ecea30..89b292e130e8f 100644 --- a/agent/proto/resourcesmonitor/resources_monitor_test.go +++ b/agent/proto/resourcesmonitor/resources_monitor_test.go @@ -195,7 +195,7 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/apiversion/apiversion_test.go b/apiversion/apiversion_test.go index 8a18a0bd5ca8e..91e93f25619e8 100644 --- a/apiversion/apiversion_test.go +++ b/apiversion/apiversion_test.go @@ -72,7 +72,7 @@ func TestAPIVersionValidate(t *testing.T) { expectedError: "no longer supported", }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/buildinfo/buildinfo_test.go b/buildinfo/buildinfo_test.go index b83c106148e9e..c50a93000171a 100644 --- a/buildinfo/buildinfo_test.go +++ b/buildinfo/buildinfo_test.go @@ -93,7 +93,7 @@ func TestBuildInfo(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2), diff --git a/cli/agent_internal_test.go b/cli/agent_internal_test.go index 910effb4191c1..42f05d30d3dc0 100644 --- a/cli/agent_internal_test.go +++ b/cli/agent_internal_test.go @@ -54,7 +54,7 @@ func Test_extractPort(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := extractPort(tt.urlString) diff --git a/cli/autoupdate_test.go b/cli/autoupdate_test.go index 51001d5109755..b108e5d547999 100644 --- a/cli/autoupdate_test.go +++ b/cli/autoupdate_test.go @@ -62,7 +62,7 @@ func TestAutoUpdate(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() client := coderdtest.New(t, nil) diff --git a/cli/clitest/golden.go b/cli/clitest/golden.go index d4401d6c5d5f9..197ae6de4f474 100644 --- a/cli/clitest/golden.go +++ b/cli/clitest/golden.go @@ -71,7 +71,7 @@ ExtractCommandPathsLoop: } for _, tt := range cases { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/cli/cliui/agent_test.go b/cli/cliui/agent_test.go index 966d53578780a..6e1b34c023be9 100644 --- a/cli/cliui/agent_test.go +++ b/cli/cliui/agent_test.go @@ -369,7 +369,7 @@ func TestAgent(t *testing.T) { wantErr: true, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -648,7 +648,7 @@ func TestPeerDiagnostics(t *testing.T) { }, } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() r, w := io.Pipe() @@ -852,7 +852,7 @@ func TestConnDiagnostics(t *testing.T) { }, } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() r, w := io.Pipe() diff --git a/cli/cliui/provisionerjob_test.go b/cli/cliui/provisionerjob_test.go index aa31c9b4a40cb..afbd61c55c76b 100644 --- a/cli/cliui/provisionerjob_test.go +++ b/cli/cliui/provisionerjob_test.go @@ -124,7 +124,6 @@ func TestProvisionerJob(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/cli/cliui/resources_internal_test.go b/cli/cliui/resources_internal_test.go index 0c76e18eb1d1f..7c69ed8f28c43 100644 --- a/cli/cliui/resources_internal_test.go +++ b/cli/cliui/resources_internal_test.go @@ -40,7 +40,7 @@ func TestRenderAgentVersion(t *testing.T) { }, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion) diff --git a/cli/cliui/table_test.go b/cli/cliui/table_test.go index 671002d713fcf..a66cb57221cf6 100644 --- a/cli/cliui/table_test.go +++ b/cli/cliui/table_test.go @@ -169,7 +169,7 @@ foo 10 [a, b, c] foo1 11 foo2 12 fo // Test with pointer values. inPtr := make([]*tableTest1, len(in)) for i, v := range in { - v := v + inPtr[i] = &v } out, err = cliui.DisplayTable(inPtr, "", nil) diff --git a/cli/cliutil/levenshtein/levenshtein_test.go b/cli/cliutil/levenshtein/levenshtein_test.go index c635ad0564181..cbad97844e677 100644 --- a/cli/cliutil/levenshtein/levenshtein_test.go +++ b/cli/cliutil/levenshtein/levenshtein_test.go @@ -95,7 +95,7 @@ func Test_Levenshtein_Matches(t *testing.T) { Expected: []string{"kubernetes"}, }, } { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() actual := levenshtein.Matches(tt.Needle, tt.MaxDistance, tt.Haystack...) @@ -179,7 +179,7 @@ func Test_Levenshtein_Distance(t *testing.T) { Error: levenshtein.ErrMaxDist.Error(), }, } { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() actual, err := levenshtein.Distance(tt.A, tt.B, tt.MaxDist) diff --git a/cli/cliutil/provisionerwarn_test.go b/cli/cliutil/provisionerwarn_test.go index a737223310d75..40b2e39f6986f 100644 --- a/cli/cliutil/provisionerwarn_test.go +++ b/cli/cliutil/provisionerwarn_test.go @@ -59,7 +59,7 @@ func TestWarnMatchedProvisioners(t *testing.T) { }, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() var w strings.Builder diff --git a/cli/configssh_internal_test.go b/cli/configssh_internal_test.go index acf534e7ae157..345933ef20a92 100644 --- a/cli/configssh_internal_test.go +++ b/cli/configssh_internal_test.go @@ -118,7 +118,7 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -157,7 +157,7 @@ func Test_sshConfigProxyCommandEscape(t *testing.T) { } // nolint:paralleltest // Fixes a flake for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("Windows doesn't typically execute via /bin/sh or cmd.exe, so this test is not applicable.") @@ -207,7 +207,7 @@ func Test_sshConfigMatchExecEscape(t *testing.T) { } // nolint:paralleltest // Fixes a flake for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { cmd := "/bin/sh" arg := "-c" @@ -290,7 +290,7 @@ func Test_sshConfigExecEscapeSeparatorForce(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() found, err := sshConfigProxyCommandEscape(tt.path, tt.forceUnix) @@ -366,7 +366,7 @@ func Test_sshConfigOptions_addOption(t *testing.T) { } for _, tt := range testCases { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/configssh_test.go b/cli/configssh_test.go index 60c93b8e94f4b..bd49e5171fcae 100644 --- a/cli/configssh_test.go +++ b/cli/configssh_test.go @@ -688,7 +688,7 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/exp_errors_test.go b/cli/exp_errors_test.go index 75272fc86d8d3..7e604c4a7e670 100644 --- a/cli/exp_errors_test.go +++ b/cli/exp_errors_test.go @@ -49,7 +49,7 @@ ExtractCommandPathsLoop: } for _, tt := range cases { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/gitauth/askpass_test.go b/cli/gitauth/askpass_test.go index d70e791c97afb..f482ceb5e296a 100644 --- a/cli/gitauth/askpass_test.go +++ b/cli/gitauth/askpass_test.go @@ -60,7 +60,7 @@ func TestParse(t *testing.T) { wantHost: "http://wow.io", }, } { - tc := tc + t.Run(tc.in, func(t *testing.T) { t.Parallel() user, host, err := gitauth.ParseAskpass(tc.in) diff --git a/cli/notifications_test.go b/cli/notifications_test.go index 5164657c6c1fb..7cd2bea5e0f62 100644 --- a/cli/notifications_test.go +++ b/cli/notifications_test.go @@ -48,7 +48,7 @@ func TestNotifications(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/open_internal_test.go b/cli/open_internal_test.go index 7af4359a56bc2..d9886a7583f59 100644 --- a/cli/open_internal_test.go +++ b/cli/open_internal_test.go @@ -47,7 +47,7 @@ func Test_resolveAgentAbsPath(t *testing.T) { {"fail with no working directory and rel path on windows", args{relOrAbsPath: "my\\path", agentOS: "windows"}, "", true}, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -156,7 +156,7 @@ func Test_buildAppLinkURL(t *testing.T) { expectedLink: "https://coder.tld/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/", }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() baseURL, err := url.Parse(tt.baseURL) diff --git a/cli/open_test.go b/cli/open_test.go index f7180ab260fbd..dce6747fce6c8 100644 --- a/cli/open_test.go +++ b/cli/open_test.go @@ -113,7 +113,7 @@ func TestOpenVSCode(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -240,7 +240,7 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -414,7 +414,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -579,7 +578,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/organizationroles.go b/cli/organizationroles.go index 4d68ab02ae78d..1c57fad4b2594 100644 --- a/cli/organizationroles.go +++ b/cli/organizationroles.go @@ -435,7 +435,7 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str // Construct new site perms with only new perms for the resource keep := make([]codersdk.Permission, 0) for _, perm := range role.OrganizationPermissions { - perm := perm + if string(perm.ResourceType) != resource { keep = append(keep, perm) } diff --git a/cli/organizationsettings.go b/cli/organizationsettings.go index 920ae41ebe1fc..9e5f373fb65ba 100644 --- a/cli/organizationsettings.go +++ b/cli/organizationsettings.go @@ -116,7 +116,7 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti } for _, set := range settings { - set := set + patch := set.Patch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, @@ -192,7 +192,7 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett } for _, set := range settings { - set := set + fetch := set.Fetch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, diff --git a/cli/portforward_internal_test.go b/cli/portforward_internal_test.go index 0d1259713dac9..ca44f8a70c956 100644 --- a/cli/portforward_internal_test.go +++ b/cli/portforward_internal_test.go @@ -103,7 +103,7 @@ func Test_parsePortForwards(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/portforward_test.go b/cli/portforward_test.go index 0be029748b3c8..337726fc4b001 100644 --- a/cli/portforward_test.go +++ b/cli/portforward_test.go @@ -145,7 +145,7 @@ func TestPortForward(t *testing.T) { ) for _, c := range cases { - c := c + t.Run(c.name+"_OnePort", func(t *testing.T) { t.Parallel() p1 := setupTestListener(t, c.setupRemote(t)) diff --git a/cli/provisionerjobs_test.go b/cli/provisionerjobs_test.go index 1566147c5311d..ddab340471b67 100644 --- a/cli/provisionerjobs_test.go +++ b/cli/provisionerjobs_test.go @@ -152,7 +152,7 @@ func TestProvisionerJobs(t *testing.T) { {"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false}, {"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false}, } { - tt := tt + wantMsg := "OK" if !tt.wantCancelled { wantMsg = "FAIL" diff --git a/cli/root_internal_test.go b/cli/root_internal_test.go index f95ab04c1c9ec..96f32f6e3fc26 100644 --- a/cli/root_internal_test.go +++ b/cli/root_internal_test.go @@ -76,7 +76,7 @@ func Test_formatExamples(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/schedule_internal_test.go b/cli/schedule_internal_test.go index cdbbb9ca6ce26..9fc24f4702e1f 100644 --- a/cli/schedule_internal_test.go +++ b/cli/schedule_internal_test.go @@ -100,7 +100,7 @@ func TestParseCLISchedule(t *testing.T) { expectedError: errInvalidTimeFormat.Error(), }, } { - testCase := testCase + //nolint:paralleltest // t.Setenv t.Run(testCase.name, func(t *testing.T) { t.Setenv("TZ", testCase.tzEnv) diff --git a/cli/schedule_test.go b/cli/schedule_test.go index 60fbf19f4db08..397ce02249655 100644 --- a/cli/schedule_test.go +++ b/cli/schedule_test.go @@ -341,7 +341,6 @@ func TestScheduleOverride(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.command, func(t *testing.T) { // Given diff --git a/cli/server.go b/cli/server.go index d9badd02d9fbf..ebc7e3328bc4f 100644 --- a/cli/server.go +++ b/cli/server.go @@ -1202,7 +1202,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. var wg sync.WaitGroup for i, provisionerDaemon := range provisionerDaemons { id := i + 1 - provisionerDaemon := provisionerDaemon + wg.Add(1) go func() { defer wg.Done() @@ -1680,7 +1680,7 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion, // Expensively check which certificate matches the client hello. for _, cert := range certs { - cert := cert + if err := hi.SupportsCertificate(&cert); err == nil { return &cert, nil } diff --git a/cli/server_internal_test.go b/cli/server_internal_test.go index b5417ceb04b8e..25f2d7f353d71 100644 --- a/cli/server_internal_test.go +++ b/cli/server_internal_test.go @@ -62,7 +62,7 @@ func Test_configureCipherSuites(t *testing.T) { cipherByName := func(cipher string) *tls.CipherSuite { for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) { if cipher == c.Name { - c := c + return c } } @@ -173,7 +173,7 @@ func Test_configureCipherSuites(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() @@ -245,7 +245,7 @@ func TestRedirectHTTPToHTTPSDeprecation(t *testing.T) { } for _, tc := range testcases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) @@ -310,7 +310,7 @@ func TestIsDERPPath(t *testing.T) { }, } for _, tc := range testcases { - tc := tc + t.Run(tc.path, func(t *testing.T) { t.Parallel() require.Equal(t, tc.expected, isDERPPath(tc.path)) @@ -363,7 +363,7 @@ func TestEscapePostgresURLUserInfo(t *testing.T) { }, } for _, tc := range testcases { - tc := tc + t.Run(tc.input, func(t *testing.T) { t.Parallel() o, err := escapePostgresURLUserInfo(tc.input) diff --git a/cli/server_test.go b/cli/server_test.go index eb3eac8fa5cd4..4346d44f1e1ff 100644 --- a/cli/server_test.go +++ b/cli/server_test.go @@ -471,7 +471,7 @@ func TestServer(t *testing.T) { expectGithubDefaultProviderConfigured: true, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { runGitHubProviderTest(t, tc) }) @@ -629,7 +629,7 @@ func TestServer(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() ctx, cancelFunc := context.WithCancel(context.Background()) @@ -883,7 +883,6 @@ func TestServer(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/cli/ssh_test.go b/cli/ssh_test.go index bee075283c083..a6dcfd62d826b 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -1517,7 +1517,7 @@ func TestSSH(t *testing.T) { pty.ExpectMatchContext(ctx, "ping pong") for i, sock := range sockets { - i := i + // Start the listener on the "local machine". l, err := net.Listen("unix", sock.local) require.NoError(t, err) @@ -1641,7 +1641,7 @@ func TestSSH(t *testing.T) { } for _, tc := range tcs { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/cli/start_test.go b/cli/start_test.go index 29fa4cdb46e5f..6358f153c482f 100644 --- a/cli/start_test.go +++ b/cli/start_test.go @@ -343,7 +343,7 @@ func TestStartAutoUpdate(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/templateedit_test.go b/cli/templateedit_test.go index d5fe730a14559..03f8d77db8dfe 100644 --- a/cli/templateedit_test.go +++ b/cli/templateedit_test.go @@ -299,7 +299,7 @@ func TestTemplateEdit(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -416,7 +416,7 @@ func TestTemplateEdit(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/cli/templatepull_test.go b/cli/templatepull_test.go index 99f23d12923cd..c3ae6446fd647 100644 --- a/cli/templatepull_test.go +++ b/cli/templatepull_test.go @@ -262,7 +262,6 @@ func TestTemplatePull_ToDir(t *testing.T) { // nolint: paralleltest // These tests change the current working dir, and is therefore unsuitable for parallelisation. for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { dir := t.TempDir() diff --git a/cli/templatepush_test.go b/cli/templatepush_test.go index e1a7e612f4ed6..d9bc7a4772f32 100644 --- a/cli/templatepush_test.go +++ b/cli/templatepush_test.go @@ -485,7 +485,7 @@ func TestTemplatePush(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/util_internal_test.go b/cli/util_internal_test.go index 5656bf2c81930..bc698e487d8e9 100644 --- a/cli/util_internal_test.go +++ b/cli/util_internal_test.go @@ -30,7 +30,7 @@ func TestDurationDisplay(t *testing.T) { {"24h1m1s", "1d"}, {"25h", "1d1h"}, } { - testCase := testCase + t.Run(testCase.Duration, func(t *testing.T) { t.Parallel() d, err := time.ParseDuration(testCase.Duration) @@ -71,7 +71,7 @@ func TestExtendedParseDuration(t *testing.T) { {"200y200y200y200y200y", 0, false}, {"9223372036854775807s", 0, false}, } { - testCase := testCase + t.Run(testCase.Duration, func(t *testing.T) { t.Parallel() actual, err := extendedParseDuration(testCase.Duration) diff --git a/cli/version_test.go b/cli/version_test.go index 5802fff6f10f0..a9e65b855fd8a 100644 --- a/cli/version_test.go +++ b/cli/version_test.go @@ -50,7 +50,7 @@ Full build of Coder, supports the server subcommand. Expected: expectedText, }, } { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) diff --git a/cli/vpndaemon_windows_test.go b/cli/vpndaemon_windows_test.go index 98c63277d4fac..019c9c7e4e86a 100644 --- a/cli/vpndaemon_windows_test.go +++ b/cli/vpndaemon_windows_test.go @@ -52,7 +52,7 @@ func TestVPNDaemonRun(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/coderd/agentapi/manifest_internal_test.go b/coderd/agentapi/manifest_internal_test.go index 33e0cb7613099..e0da7b1c23670 100644 --- a/coderd/agentapi/manifest_internal_test.go +++ b/coderd/agentapi/manifest_internal_test.go @@ -80,7 +80,7 @@ func Test_vscodeProxyURI(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/agentapi/resources_monitoring_test.go b/coderd/agentapi/resources_monitoring_test.go index 087ccfd24e459..d64a25d278be8 100644 --- a/coderd/agentapi/resources_monitoring_test.go +++ b/coderd/agentapi/resources_monitoring_test.go @@ -280,7 +280,6 @@ func TestMemoryResourceMonitor(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -713,7 +712,6 @@ func TestVolumeResourceMonitor(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/agentmetrics/labels_test.go b/coderd/agentmetrics/labels_test.go index b383ca0b25c0d..a32c8f7bf52b7 100644 --- a/coderd/agentmetrics/labels_test.go +++ b/coderd/agentmetrics/labels_test.go @@ -43,7 +43,6 @@ func TestValidateAggregationLabels(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/apikey/apikey_test.go b/coderd/apikey/apikey_test.go index ef4d260ddf0a6..8da27674dbf2b 100644 --- a/coderd/apikey/apikey_test.go +++ b/coderd/apikey/apikey_test.go @@ -107,7 +107,7 @@ func TestGenerate(t *testing.T) { } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/audit_test.go b/coderd/audit_test.go index 18bcd78b38807..ca4cd3b9bda96 100644 --- a/coderd/audit_test.go +++ b/coderd/audit_test.go @@ -454,7 +454,7 @@ func TestAuditLogsFilter(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + // Test filtering t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/authorize_test.go b/coderd/authorize_test.go index 3af6cfd7d620e..4399fed7bf13c 100644 --- a/coderd/authorize_test.go +++ b/coderd/authorize_test.go @@ -125,7 +125,6 @@ func TestCheckPermissions(t *testing.T) { } for _, c := range testCases { - c := c t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/autobuild/lifecycle_executor_internal_test.go b/coderd/autobuild/lifecycle_executor_internal_test.go index bfe3bb53592b3..e8c472fed89d6 100644 --- a/coderd/autobuild/lifecycle_executor_internal_test.go +++ b/coderd/autobuild/lifecycle_executor_internal_test.go @@ -153,7 +153,7 @@ func Test_isEligibleForAutostart(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/autobuild/lifecycle_executor_test.go b/coderd/autobuild/lifecycle_executor_test.go index 453de63031a47..38f34aef37720 100644 --- a/coderd/autobuild/lifecycle_executor_test.go +++ b/coderd/autobuild/lifecycle_executor_test.go @@ -177,7 +177,7 @@ func TestExecutorAutostartTemplateUpdated(t *testing.T) { }, } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() var ( diff --git a/coderd/autobuild/notify/notifier_test.go b/coderd/autobuild/notify/notifier_test.go index aa060406d30a1..b105b43797c10 100644 --- a/coderd/autobuild/notify/notifier_test.go +++ b/coderd/autobuild/notify/notifier_test.go @@ -83,7 +83,7 @@ func TestNotifier(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/azureidentity/azureidentity_test.go b/coderd/azureidentity/azureidentity_test.go index bd55ae2538d3a..fcbcc0c4ba8cb 100644 --- a/coderd/azureidentity/azureidentity_test.go +++ b/coderd/azureidentity/azureidentity_test.go @@ -47,7 +47,7 @@ func TestValidate(t *testing.T) { vmID: "960a4b4a-dab2-44ef-9b73-7753043b4f16", date: mustTime(time.RFC3339, "2024-04-22T17:32:44Z"), }} { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() vm, err := azureidentity.Validate(context.Background(), tc.payload, azureidentity.Options{ diff --git a/coderd/coderd_internal_test.go b/coderd/coderd_internal_test.go index 34f5738bf90a0..e4d7c18b6bad9 100644 --- a/coderd/coderd_internal_test.go +++ b/coderd/coderd_internal_test.go @@ -32,7 +32,6 @@ func TestStripSlashesMW(t *testing.T) { }) for _, tt := range tests { - tt := tt t.Run("chi/"+tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/db2sdk/db2sdk_test.go b/coderd/database/db2sdk/db2sdk_test.go index bfee2f52cbbd9..dfe3032e46db5 100644 --- a/coderd/database/db2sdk/db2sdk_test.go +++ b/coderd/database/db2sdk/db2sdk_test.go @@ -119,8 +119,7 @@ func TestProvisionerJobStatus(t *testing.T) { org := dbgen.Organization(t, db, database.Organization{}) for i, tc := range cases { - tc := tc - i := i + t.Run(tc.name, func(t *testing.T) { t.Parallel() // Populate standard fields diff --git a/coderd/database/dbauthz/customroles_test.go b/coderd/database/dbauthz/customroles_test.go index 815d6629f64f9..d27a29392aef8 100644 --- a/coderd/database/dbauthz/customroles_test.go +++ b/coderd/database/dbauthz/customroles_test.go @@ -46,7 +46,7 @@ func TestInsertCustomRoles(t *testing.T) { merge := func(u ...interface{}) rbac.Roles { all := make([]rbac.Role, 0) for _, v := range u { - v := v + switch t := v.(type) { case rbac.Role: all = append(all, t) @@ -201,7 +201,6 @@ func TestInsertCustomRoles(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/dbauthz/groupsauth_test.go b/coderd/database/dbauthz/groupsauth_test.go index a9f26e303d644..e8a52677e85f5 100644 --- a/coderd/database/dbauthz/groupsauth_test.go +++ b/coderd/database/dbauthz/groupsauth_test.go @@ -135,7 +135,7 @@ func TestGroupsAuth(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/dbauthz/setup_test.go b/coderd/database/dbauthz/setup_test.go index 776667ba053cc..746b1f28dd0bf 100644 --- a/coderd/database/dbauthz/setup_test.go +++ b/coderd/database/dbauthz/setup_test.go @@ -458,7 +458,7 @@ type AssertRBAC struct { func values(ins ...any) []reflect.Value { out := make([]reflect.Value, 0) for _, input := range ins { - input := input + out = append(out, reflect.ValueOf(input)) } return out diff --git a/coderd/database/dbmem/dbmem.go b/coderd/database/dbmem/dbmem.go index ab2dd923dab47..d0db6000a6a73 100644 --- a/coderd/database/dbmem/dbmem.go +++ b/coderd/database/dbmem/dbmem.go @@ -1797,7 +1797,7 @@ func (q *FakeQuerier) CustomRoles(_ context.Context, arg database.CustomRolesPar found := make([]database.CustomRole, 0) for _, role := range q.data.customRoles { - role := role + if len(arg.LookupRoles) > 0 { if !slices.ContainsFunc(arg.LookupRoles, func(pair database.NameOrganizationPair) bool { if pair.Name != role.Name { @@ -2867,7 +2867,7 @@ func (q *FakeQuerier) GetAuthorizationUserRoles(_ context.Context, userID uuid.U roles := make([]string, 0) for _, u := range q.users { if u.ID == userID { - u := u + roles = append(roles, u.RBACRoles...) roles = append(roles, "member") user = &u @@ -8070,7 +8070,7 @@ func (q *FakeQuerier) GetWorkspaceByOwnerIDAndName(_ context.Context, arg databa var found *database.WorkspaceTable for _, workspace := range q.workspaces { - workspace := workspace + if workspace.OwnerID != arg.OwnerID { continue } @@ -8128,7 +8128,7 @@ func (q *FakeQuerier) GetWorkspaceByWorkspaceAppID(_ context.Context, workspaceA defer q.mutex.RUnlock() for _, workspaceApp := range q.workspaceApps { - workspaceApp := workspaceApp + if workspaceApp.ID == workspaceAppID { return q.getWorkspaceByAgentIDNoLock(context.Background(), workspaceApp.AgentID) } @@ -10339,7 +10339,6 @@ func (q *FakeQuerier) OrganizationMembers(_ context.Context, arg database.Organi continue } - organizationMember := organizationMember user, _ := q.getUserByIDNoLock(organizationMember.UserID) tmp = append(tmp, database.OrganizationMembersRow{ OrganizationMember: organizationMember, diff --git a/coderd/database/dbmem/dbmem_test.go b/coderd/database/dbmem/dbmem_test.go index 11d30e61a895d..af53f0f02fecc 100644 --- a/coderd/database/dbmem/dbmem_test.go +++ b/coderd/database/dbmem/dbmem_test.go @@ -188,7 +188,7 @@ func TestProxyByHostname(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/migrations/migrate_test.go b/coderd/database/migrations/migrate_test.go index cd843bd97aa7a..f99c523a2c702 100644 --- a/coderd/database/migrations/migrate_test.go +++ b/coderd/database/migrations/migrate_test.go @@ -288,7 +288,6 @@ func TestMigrateUpWithFixtures(t *testing.T) { }) for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/pubsub/pubsub_memory.go b/coderd/database/pubsub/pubsub_memory.go index c4766c3dfa3fb..1d4330ab1ff8f 100644 --- a/coderd/database/pubsub/pubsub_memory.go +++ b/coderd/database/pubsub/pubsub_memory.go @@ -73,7 +73,7 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error { var wg sync.WaitGroup for _, listener := range listeners { wg.Add(1) - listener := listener + go func() { defer wg.Done() listener.send(context.Background(), message) diff --git a/coderd/database/querier_test.go b/coderd/database/querier_test.go index 74ac5b0a20caf..159b96ea3891e 100644 --- a/coderd/database/querier_test.go +++ b/coderd/database/querier_test.go @@ -1157,7 +1157,7 @@ func TestProxyByHostname(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -1395,7 +1395,7 @@ func TestGetUsers_IncludeSystem(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1863,7 +1863,6 @@ func TestReadCustomRoles(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -2507,7 +2506,7 @@ func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) { } for _, tc := range testCases { - tc := tc // Capture loop variable to avoid data races + // Capture loop variable to avoid data races t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -2948,7 +2947,7 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tz := range timezones { - tz := tz + t.Run(tz, func(t *testing.T) { t.Parallel() @@ -2996,7 +2995,7 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -3164,7 +3163,7 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -3297,7 +3296,7 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/devtunnel/tunnel_test.go b/coderd/devtunnel/tunnel_test.go index ca1c5b7752628..64a3da023bad2 100644 --- a/coderd/devtunnel/tunnel_test.go +++ b/coderd/devtunnel/tunnel_test.go @@ -48,7 +48,6 @@ func TestTunnel(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/externalauth/externalauth.go b/coderd/externalauth/externalauth.go index 600aacf62f7dd..de443967ed9f5 100644 --- a/coderd/externalauth/externalauth.go +++ b/coderd/externalauth/externalauth.go @@ -505,7 +505,6 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut ids := map[string]struct{}{} configs := []*Config{} for _, entry := range entries { - entry := entry // Applies defaults to the config entry. // This allows users to very simply state that they type is "GitHub", diff --git a/coderd/externalauth/externalauth_internal_test.go b/coderd/externalauth/externalauth_internal_test.go index 26515ff78f215..e72fabd1e3f97 100644 --- a/coderd/externalauth/externalauth_internal_test.go +++ b/coderd/externalauth/externalauth_internal_test.go @@ -102,7 +102,7 @@ func TestGitlabDefaults(t *testing.T) { }, } for _, c := range tests { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() applyDefaultsToConfig(&c.input) @@ -177,7 +177,7 @@ func Test_bitbucketServerConfigDefaults(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() applyDefaultsToConfig(tt.config) diff --git a/coderd/externalauth/externalauth_test.go b/coderd/externalauth/externalauth_test.go index ec540fba2eac6..1aff61c4179b9 100644 --- a/coderd/externalauth/externalauth_test.go +++ b/coderd/externalauth/externalauth_test.go @@ -463,7 +463,7 @@ func TestConvertYAML(t *testing.T) { }}, Error: "device auth url must be provided", }} { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() output, err := externalauth.ConvertConfig(instrument, tc.Input, &url.URL{}) diff --git a/coderd/healthcheck/health/model_test.go b/coderd/healthcheck/health/model_test.go index 8b28dc5862517..dd47cbf6003e6 100644 --- a/coderd/healthcheck/health/model_test.go +++ b/coderd/healthcheck/health/model_test.go @@ -21,7 +21,7 @@ func Test_MessageURL(t *testing.T) { {"default", health.CodeAccessURLFetch, "", "https://coder.com/docs/admin/monitoring/health-check#eacs03"}, {"custom docs base", health.CodeAccessURLFetch, "https://example.com/docs", "https://example.com/docs/admin/monitoring/health-check#eacs03"}, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() uut := health.Message{Code: tt.code} diff --git a/coderd/healthcheck/healthcheck_test.go b/coderd/healthcheck/healthcheck_test.go index 9c744b42d1dca..96da80148aced 100644 --- a/coderd/healthcheck/healthcheck_test.go +++ b/coderd/healthcheck/healthcheck_test.go @@ -508,7 +508,7 @@ func TestHealthcheck(t *testing.T) { }, severity: health.SeverityError, }} { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/provisioner_test.go b/coderd/healthcheck/provisioner_test.go index 93871f4a709ad..723daee0203ee 100644 --- a/coderd/healthcheck/provisioner_test.go +++ b/coderd/healthcheck/provisioner_test.go @@ -335,7 +335,7 @@ func TestProvisionerDaemonReport(t *testing.T) { expectedItems: []healthsdk.ProvisionerDaemonsReportItem{}, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/workspaceproxy_internal_test.go b/coderd/healthcheck/workspaceproxy_internal_test.go index 5a7875518df7e..395103c3b6f9e 100644 --- a/coderd/healthcheck/workspaceproxy_internal_test.go +++ b/coderd/healthcheck/workspaceproxy_internal_test.go @@ -47,7 +47,7 @@ func Test_WorkspaceProxyReport_appendErrors(t *testing.T) { errs: []string{assert.AnError.Error(), "another error"}, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -85,7 +85,7 @@ func Test_calculateSeverity(t *testing.T) { {2, 0, 0, health.SeverityError}, {2, 0, 1, health.SeverityError}, } { - tt := tt + name := fmt.Sprintf("%d total, %d healthy, %d warning -> %s", tt.total, tt.healthy, tt.warning, tt.expected) t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/workspaceproxy_test.go b/coderd/healthcheck/workspaceproxy_test.go index d5bd5c12210b8..84c10a86330ff 100644 --- a/coderd/healthcheck/workspaceproxy_test.go +++ b/coderd/healthcheck/workspaceproxy_test.go @@ -172,7 +172,7 @@ func TestWorkspaceProxies(t *testing.T) { expectedSeverity: health.SeverityError, }, } { - tt := tt + if tt.name != "Enabled/ProxyWarnings" { continue } diff --git a/coderd/httpapi/cookie_test.go b/coderd/httpapi/cookie_test.go index 4d44cd8f7d130..e771afab606b9 100644 --- a/coderd/httpapi/cookie_test.go +++ b/coderd/httpapi/cookie_test.go @@ -26,7 +26,7 @@ func TestStripCoderCookies(t *testing.T) { "coder_session_token=ok; oauth_state=wow; oauth_redirect=/", "", }} { - tc := tc + t.Run(tc.Input, func(t *testing.T) { t.Parallel() require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input)) diff --git a/coderd/httpapi/json_test.go b/coderd/httpapi/json_test.go index a0a93e884d44f..cd6ef58e6b00f 100644 --- a/coderd/httpapi/json_test.go +++ b/coderd/httpapi/json_test.go @@ -46,7 +46,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.expected, func(t *testing.T) { t.Parallel() @@ -109,7 +108,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.value, func(t *testing.T) { t.Parallel() @@ -153,7 +151,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.value, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/authorize_test.go b/coderd/httpmw/authorize_test.go index 3ee9d92742252..55f68660e8146 100644 --- a/coderd/httpmw/authorize_test.go +++ b/coderd/httpmw/authorize_test.go @@ -107,7 +107,7 @@ func TestExtractUserRoles(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/cors_test.go b/coderd/httpmw/cors_test.go index 57111799ff292..0eecc296f476a 100644 --- a/coderd/httpmw/cors_test.go +++ b/coderd/httpmw/cors_test.go @@ -91,7 +91,7 @@ func TestWorkspaceAppCors(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/csrf_test.go b/coderd/httpmw/csrf_test.go index 9e8094ad50d6d..65a33a74adeb5 100644 --- a/coderd/httpmw/csrf_test.go +++ b/coderd/httpmw/csrf_test.go @@ -57,7 +57,7 @@ func TestCSRFExemptList(t *testing.T) { csrfmw := mw(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})).(*nosurf.CSRFHandler) for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/hsts_test.go b/coderd/httpmw/hsts_test.go index 3bc3463e69e65..3d9b543c8772d 100644 --- a/coderd/httpmw/hsts_test.go +++ b/coderd/httpmw/hsts_test.go @@ -77,7 +77,7 @@ func TestHSTS(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/loggermw/logger_internal_test.go b/coderd/httpmw/loggermw/logger_internal_test.go index 53cc9f4eb9462..de846ba0eedd4 100644 --- a/coderd/httpmw/loggermw/logger_internal_test.go +++ b/coderd/httpmw/loggermw/logger_internal_test.go @@ -247,7 +247,7 @@ func TestRequestLogger_RouteParamsLogging(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/patternmatcher/routepatterns_test.go b/coderd/httpmw/patternmatcher/routepatterns_test.go index 58d914d231e90..992eed72356eb 100644 --- a/coderd/httpmw/patternmatcher/routepatterns_test.go +++ b/coderd/httpmw/patternmatcher/routepatterns_test.go @@ -108,7 +108,7 @@ func Test_RoutePatterns(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/realip_test.go b/coderd/httpmw/realip_test.go index 3070070bd90d8..f53b9397357c0 100644 --- a/coderd/httpmw/realip_test.go +++ b/coderd/httpmw/realip_test.go @@ -200,7 +200,7 @@ func TestExtractAddress(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.Name, func(t *testing.T) { t.Parallel() @@ -235,9 +235,7 @@ func TestTrustedOrigins(t *testing.T) { // ipv6: trust an IPv4 network for _, trusted := range []string{"none", "ipv4", "ipv6"} { for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - trusted := trusted - header := header - proto := proto + name := fmt.Sprintf("%s-%s-%s", trusted, proto, strings.ToLower(header)) t.Run(name, func(t *testing.T) { @@ -311,7 +309,7 @@ func TestCorruptedHeaders(t *testing.T) { t.Parallel() for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - header := header + name := strings.ToLower(header) t.Run(name, func(t *testing.T) { @@ -364,9 +362,7 @@ func TestAddressFamilies(t *testing.T) { for _, clientFamily := range []string{"ipv4", "ipv6"} { for _, proxyFamily := range []string{"ipv4", "ipv6"} { for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - clientFamily := clientFamily - proxyFamily := proxyFamily - header := header + name := fmt.Sprintf("%s-%s-%s", strings.ToLower(header), clientFamily, proxyFamily) t.Run(name, func(t *testing.T) { @@ -466,7 +462,7 @@ func TestFilterUntrusted(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.Name, func(t *testing.T) { t.Parallel() @@ -612,7 +608,7 @@ func TestApplicationProxy(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/recover_test.go b/coderd/httpmw/recover_test.go index b76c5b105baf5..1f22247155a81 100644 --- a/coderd/httpmw/recover_test.go +++ b/coderd/httpmw/recover_test.go @@ -52,7 +52,6 @@ func TestRecover(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/workspaceparam_test.go b/coderd/httpmw/workspaceparam_test.go index 33b0c753068f7..4dfddc08513c2 100644 --- a/coderd/httpmw/workspaceparam_test.go +++ b/coderd/httpmw/workspaceparam_test.go @@ -316,7 +316,7 @@ func TestWorkspaceAgentByNameParam(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() db, r := setupWorkspaceWithAgents(t, setupConfig{ diff --git a/coderd/idpsync/group.go b/coderd/idpsync/group.go index b5d8003165665..54b8430b78da8 100644 --- a/coderd/idpsync/group.go +++ b/coderd/idpsync/group.go @@ -99,7 +99,7 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat // membership via the groups the user is in. userOrgs := make(map[uuid.UUID][]database.GetGroupsRow) for _, g := range userGroups { - g := g + userOrgs[g.Group.OrganizationID] = append(userOrgs[g.Group.OrganizationID], g) } @@ -337,7 +337,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai groups := make([]ExpectedGroup, 0) for _, group := range parsedGroups { - group := group // Legacy group mappings happen before the regex filter. mappedGroupName, ok := s.LegacyNameMapping[group] @@ -355,7 +354,7 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai mappedGroupIDs, ok := s.Mapping[group] if ok { for _, gid := range mappedGroupIDs { - gid := gid + groups = append(groups, ExpectedGroup{OrganizationID: orgID, GroupID: &gid}) } continue diff --git a/coderd/idpsync/group_test.go b/coderd/idpsync/group_test.go index 7b0fb70ae8f68..d8a9802ecc3c6 100644 --- a/coderd/idpsync/group_test.go +++ b/coderd/idpsync/group_test.go @@ -243,7 +243,7 @@ func TestGroupSyncTable(t *testing.T) { } for _, tc := range testCases { - tc := tc + // The final test, "AllTogether", cannot run in parallel. // These tests are nearly instant using the memory db, so // this is still fast without being in parallel. @@ -341,7 +341,6 @@ func TestGroupSyncTable(t *testing.T) { }) for _, tc := range testCases { - tc := tc orgID := uuid.New() SetupOrganization(t, s, db, user, orgID, tc) @@ -523,7 +522,7 @@ func TestApplyGroupDifference(t *testing.T) { } for _, tc := range testCase { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -713,7 +712,7 @@ func TestExpectedGroupEqual(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/idpsync/idpsync_test.go b/coderd/idpsync/idpsync_test.go index 0db5c66bed174..7a5b6d2e19d17 100644 --- a/coderd/idpsync/idpsync_test.go +++ b/coderd/idpsync/idpsync_test.go @@ -159,7 +159,7 @@ func TestParseStringSliceClaim(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/idpsync/role_test.go b/coderd/idpsync/role_test.go index f07d97a2b0f31..d195ab4422a6c 100644 --- a/coderd/idpsync/role_test.go +++ b/coderd/idpsync/role_test.go @@ -186,7 +186,7 @@ func TestRoleSyncTable(t *testing.T) { } for _, tc := range testCases { - tc := tc + // The final test, "AllTogether", cannot run in parallel. // These tests are nearly instant using the memory db, so // this is still fast without being in parallel. @@ -248,7 +248,6 @@ func TestRoleSyncTable(t *testing.T) { var asserts []func(t *testing.T) for _, tc := range testCases { - tc := tc orgID := uuid.New() SetupOrganization(t, s, db, user, orgID, tc) diff --git a/coderd/inboxnotifications_internal_test.go b/coderd/inboxnotifications_internal_test.go index e7d9a85d3e74f..4d84a1cc16a21 100644 --- a/coderd/inboxnotifications_internal_test.go +++ b/coderd/inboxnotifications_internal_test.go @@ -29,7 +29,6 @@ func TestInboxNotifications_ensureNotificationIcon(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/inboxnotifications_test.go b/coderd/inboxnotifications_test.go index 82ae539518ae0..22deb81ce4df6 100644 --- a/coderd/inboxnotifications_test.go +++ b/coderd/inboxnotifications_test.go @@ -57,7 +57,7 @@ func TestInboxNotification_Watch(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -393,7 +393,7 @@ func TestInboxNotifications_List(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/insights_internal_test.go b/coderd/insights_internal_test.go index 111bd268e8855..b0867c944d268 100644 --- a/coderd/insights_internal_test.go +++ b/coderd/insights_internal_test.go @@ -144,7 +144,7 @@ func Test_parseInsightsStartAndEndTime(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -253,7 +253,6 @@ func Test_parseInsightsInterval_week(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -323,7 +322,7 @@ func TestLastReportIntervalHasAtLeastSixDays(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/insights_test.go b/coderd/insights_test.go index 693bb48811acc..8f323c38785f2 100644 --- a/coderd/insights_test.go +++ b/coderd/insights_test.go @@ -550,7 +550,6 @@ func TestTemplateInsights_Golden(t *testing.T) { // Prepare all the templates. for _, template := range templates { - template := template var parameters []*proto.RichParameter for _, parameter := range template.parameters { @@ -582,9 +581,8 @@ func TestTemplateInsights_Golden(t *testing.T) { ) var resources []*proto.Resource for _, user := range users { - user := user + for _, workspace := range user.workspaces { - workspace := workspace if workspace.template != template { continue @@ -1246,7 +1244,7 @@ func TestTemplateInsights_Golden(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1261,7 +1259,7 @@ func TestTemplateInsights_Golden(t *testing.T) { _, _ = <-events, <-events for _, req := range tt.requests { - req := req + t.Run(req.name, func(t *testing.T) { t.Parallel() @@ -1489,7 +1487,6 @@ func TestUserActivityInsights_Golden(t *testing.T) { // Prepare all the templates. for _, template := range templates { - template := template // Prepare all workspace resources (agents and apps). var ( @@ -1498,9 +1495,8 @@ func TestUserActivityInsights_Golden(t *testing.T) { ) var resources []*proto.Resource for _, user := range users { - user := user + for _, workspace := range user.workspaces { - workspace := workspace if workspace.template != template { continue @@ -2031,7 +2027,7 @@ func TestUserActivityInsights_Golden(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -2046,7 +2042,7 @@ func TestUserActivityInsights_Golden(t *testing.T) { _, _ = <-events, <-events for _, req := range tt.requests { - req := req + t.Run(req.name, func(t *testing.T) { t.Parallel() @@ -2159,7 +2155,6 @@ func TestTemplateInsights_RBAC(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) { t.Parallel() @@ -2279,8 +2274,6 @@ func TestGenericInsights_RBAC(t *testing.T) { } for endpointName, endpoint := range endpoints { - endpointName := endpointName - endpoint := endpoint t.Run(fmt.Sprintf("With%sEndpoint", endpointName), func(t *testing.T) { t.Parallel() @@ -2291,7 +2284,6 @@ func TestGenericInsights_RBAC(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run("AsOwner", func(t *testing.T) { t.Parallel() diff --git a/coderd/jobreaper/detector_test.go b/coderd/jobreaper/detector_test.go index 28457aeeca3a8..676ad5ee929c4 100644 --- a/coderd/jobreaper/detector_test.go +++ b/coderd/jobreaper/detector_test.go @@ -844,7 +844,6 @@ func TestDetectorPushesLogs(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/jwtutils/jwt_test.go b/coderd/jwtutils/jwt_test.go index a2126092ff015..2920398cdd239 100644 --- a/coderd/jwtutils/jwt_test.go +++ b/coderd/jwtutils/jwt_test.go @@ -149,12 +149,11 @@ func TestClaims(t *testing.T) { } for _, tt := range types { - tt := tt t.Run(tt.Name, func(t *testing.T) { t.Parallel() for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/metricscache/metricscache_test.go b/coderd/metricscache/metricscache_test.go index 53852f41c904b..61aec9117f9ce 100644 --- a/coderd/metricscache/metricscache_test.go +++ b/coderd/metricscache/metricscache_test.go @@ -202,7 +202,7 @@ func TestCache_BuildTime(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/dispatch/inbox_test.go b/coderd/notifications/dispatch/inbox_test.go index a06b698e9769a..4b4b2abb40920 100644 --- a/coderd/notifications/dispatch/inbox_test.go +++ b/coderd/notifications/dispatch/inbox_test.go @@ -69,7 +69,7 @@ func TestInbox(t *testing.T) { } for _, tc := range tests { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/notifications_test.go b/coderd/notifications/notifications_test.go index b3e087a9e7d8f..17487e69681b6 100644 --- a/coderd/notifications/notifications_test.go +++ b/coderd/notifications/notifications_test.go @@ -1283,7 +1283,6 @@ func TestNotificationTemplates_Golden(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -2006,7 +2005,6 @@ func TestNotificationTargetMatrix(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/render/gotmpl_test.go b/coderd/notifications/render/gotmpl_test.go index 25e52cc07f671..8ed102c58193e 100644 --- a/coderd/notifications/render/gotmpl_test.go +++ b/coderd/notifications/render/gotmpl_test.go @@ -68,7 +68,7 @@ func TestGoTemplate(t *testing.T) { } for _, tc := range tests { - tc := tc // unnecessary as of go1.22 but the linter is outdated + // unnecessary as of go1.22 but the linter is outdated t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/oauth2_test.go b/coderd/oauth2_test.go index f5311be173bac..4dc81361b4741 100644 --- a/coderd/oauth2_test.go +++ b/coderd/oauth2_test.go @@ -151,7 +151,7 @@ func TestOAuth2ProviderApps(t *testing.T) { require.NoError(t, err) for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -661,7 +661,7 @@ func TestOAuth2ProviderTokenExchange(t *testing.T) { }, } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -804,7 +804,7 @@ func TestOAuth2ProviderTokenRefresh(t *testing.T) { }, } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -996,7 +996,7 @@ func TestOAuth2ProviderRevoke(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/coderd/pagination_internal_test.go b/coderd/pagination_internal_test.go index adcfde6bbb641..b1b8d18c746a3 100644 --- a/coderd/pagination_internal_test.go +++ b/coderd/pagination_internal_test.go @@ -110,7 +110,7 @@ func TestPagination(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() rw := httptest.NewRecorder() diff --git a/coderd/prebuilds/preset_snapshot_test.go b/coderd/prebuilds/preset_snapshot_test.go index fcaf6ff79ec0f..d626021c034e2 100644 --- a/coderd/prebuilds/preset_snapshot_test.go +++ b/coderd/prebuilds/preset_snapshot_test.go @@ -418,7 +418,7 @@ func TestInProgressActions(t *testing.T) { } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -648,7 +648,7 @@ func TestExpiredPrebuilds(t *testing.T) { } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/presets_test.go b/coderd/presets_test.go index dc47b10cfd36f..29516d4c9334f 100644 --- a/coderd/presets_test.go +++ b/coderd/presets_test.go @@ -78,7 +78,7 @@ func TestTemplateVersionPresets(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/prometheusmetrics/aggregator_test.go b/coderd/prometheusmetrics/aggregator_test.go index 0930f186bd328..2e1128b13004a 100644 --- a/coderd/prometheusmetrics/aggregator_test.go +++ b/coderd/prometheusmetrics/aggregator_test.go @@ -587,7 +587,6 @@ func TestLabelsAggregation(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/prometheusmetrics/prometheusmetrics_internal_test.go b/coderd/prometheusmetrics/prometheusmetrics_internal_test.go index 5eaf1d92ed67f..5af912225e22c 100644 --- a/coderd/prometheusmetrics/prometheusmetrics_internal_test.go +++ b/coderd/prometheusmetrics/prometheusmetrics_internal_test.go @@ -29,7 +29,6 @@ func TestFilterAcceptableAgentLabels(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/prometheusmetrics/prometheusmetrics_test.go b/coderd/prometheusmetrics/prometheusmetrics_test.go index 34309042c5f55..be2ffe129ea8f 100644 --- a/coderd/prometheusmetrics/prometheusmetrics_test.go +++ b/coderd/prometheusmetrics/prometheusmetrics_test.go @@ -99,7 +99,7 @@ func TestActiveUsers(t *testing.T) { }, Count: 2, }} { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -161,7 +161,7 @@ func TestUsers(t *testing.T) { }, Count: map[database.UserStatus]int{database.UserStatusActive: 3}, }} { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) @@ -250,7 +250,7 @@ func TestWorkspaceLatestBuildTotals(t *testing.T) { codersdk.ProvisionerJobRunning: 1, }, }} { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -327,7 +327,7 @@ func TestWorkspaceLatestBuildStatuses(t *testing.T) { codersdk.ProvisionerJobRunning: 1, }, }} { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -660,7 +660,6 @@ func TestExperimentsMetric(t *testing.T) { } for _, tc := range tests { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/promoauth/oauth2_test.go b/coderd/promoauth/oauth2_test.go index 9e31d90944f36..1ed0d7da6f1af 100644 --- a/coderd/promoauth/oauth2_test.go +++ b/coderd/promoauth/oauth2_test.go @@ -155,7 +155,7 @@ func TestGithubRateLimits(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/provisionerdserver/acquirer_test.go b/coderd/provisionerdserver/acquirer_test.go index e90fb3df0198a..627eddbe09985 100644 --- a/coderd/provisionerdserver/acquirer_test.go +++ b/coderd/provisionerdserver/acquirer_test.go @@ -466,7 +466,7 @@ func TestAcquirer_MatchTags(t *testing.T) { }, } for _, tt := range testCases { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 695437068f50f..3a3cae1e86d2c 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -150,7 +150,7 @@ func TestAcquireJob(t *testing.T) { }}, } for _, tc := range cases { - tc := tc + t.Run(tc.name+"_InitiatorNotFound", func(t *testing.T) { t.Parallel() srv, db, _, pd := setup(t, false, nil) @@ -176,7 +176,7 @@ func TestAcquireJob(t *testing.T) { sdkproto.PrebuiltWorkspaceBuildStage_CREATE, sdkproto.PrebuiltWorkspaceBuildStage_CLAIM, } { - prebuiltWorkspaceBuildStage := prebuiltWorkspaceBuildStage + t.Run(tc.name+"_WorkspaceBuildJob_Stage"+prebuiltWorkspaceBuildStage.String(), func(t *testing.T) { t.Parallel() // Set the max session token lifetime so we can assert we @@ -1709,7 +1709,6 @@ func TestCompleteJob(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -2134,7 +2133,6 @@ func TestCompleteJob(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -2579,7 +2577,7 @@ func TestInsertWorkspacePresetsAndParameters(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/provisionerjobs_internal_test.go b/coderd/provisionerjobs_internal_test.go index f3bc2eb1dea99..6d9da70b747e6 100644 --- a/coderd/provisionerjobs_internal_test.go +++ b/coderd/provisionerjobs_internal_test.go @@ -132,7 +132,7 @@ func TestConvertProvisionerJob_Unit(t *testing.T) { }, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual := convertProvisionerJob(database.GetProvisionerJobsByIDsWithQueuePositionRow{ diff --git a/coderd/rbac/authz.go b/coderd/rbac/authz.go index a7f77d57ab253..5afd76f02a433 100644 --- a/coderd/rbac/authz.go +++ b/coderd/rbac/authz.go @@ -760,7 +760,7 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string, uniqueRoleNames := actor.SafeRoleNames() roleStrings := make([]string, 0, len(uniqueRoleNames)) for _, roleName := range uniqueRoleNames { - roleName := roleName + roleStrings = append(roleStrings, roleName.String()) } return trace.WithAttributes( diff --git a/coderd/rbac/authz_internal_test.go b/coderd/rbac/authz_internal_test.go index 9c09837c7915d..e1785f7e3a15e 100644 --- a/coderd/rbac/authz_internal_test.go +++ b/coderd/rbac/authz_internal_test.go @@ -243,7 +243,7 @@ func TestFilter(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() actor := tc.Actor @@ -1135,7 +1135,7 @@ func testAuthorize(t *testing.T, name string, subject Subject, sets ...[]authTes authorizer := NewAuthorizer(prometheus.NewRegistry()) for _, cases := range sets { for i, c := range cases { - c := c + caseName := fmt.Sprintf("%s/%d", name, i) t.Run(caseName, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/object_test.go b/coderd/rbac/object_test.go index ea6031f2ccae8..b64534c7950bb 100644 --- a/coderd/rbac/object_test.go +++ b/coderd/rbac/object_test.go @@ -165,7 +165,7 @@ func TestObjectEqual(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/regosql/compile_test.go b/coderd/rbac/regosql/compile_test.go index a6b59d1fdd4bd..0137e7a10a911 100644 --- a/coderd/rbac/regosql/compile_test.go +++ b/coderd/rbac/regosql/compile_test.go @@ -265,7 +265,7 @@ neq(input.object.owner, ""); } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() part := partialQueries(tc.Queries...) diff --git a/coderd/rbac/regosql/sqltypes/equality_test.go b/coderd/rbac/regosql/sqltypes/equality_test.go index 17a3d7f45eed1..cafe1870f283e 100644 --- a/coderd/rbac/regosql/sqltypes/equality_test.go +++ b/coderd/rbac/regosql/sqltypes/equality_test.go @@ -114,7 +114,7 @@ func TestEquality(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/regosql/sqltypes/member_test.go b/coderd/rbac/regosql/sqltypes/member_test.go index 0fedcc176c49f..aece83bd0ccf9 100644 --- a/coderd/rbac/regosql/sqltypes/member_test.go +++ b/coderd/rbac/regosql/sqltypes/member_test.go @@ -92,7 +92,7 @@ func TestMembership(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/roles.go b/coderd/rbac/roles.go index 28ddc38462ce9..49c7b01d58518 100644 --- a/coderd/rbac/roles.go +++ b/coderd/rbac/roles.go @@ -837,7 +837,7 @@ func Permissions(perms map[string][]policy.Action) []Permission { list := make([]Permission, 0, len(perms)) for k, actions := range perms { for _, act := range actions { - act := act + list = append(list, Permission{ Negate: false, ResourceType: k, diff --git a/coderd/rbac/roles_internal_test.go b/coderd/rbac/roles_internal_test.go index 3f2d0d89fe455..694b3400939b2 100644 --- a/coderd/rbac/roles_internal_test.go +++ b/coderd/rbac/roles_internal_test.go @@ -229,7 +229,7 @@ func TestRoleByName(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Role.Identifier.String(), func(t *testing.T) { role, err := RoleByName(c.Role.Identifier) require.NoError(t, err, "role exists") diff --git a/coderd/rbac/roles_test.go b/coderd/rbac/roles_test.go index 5738edfe8caa2..bb3d95c950ce4 100644 --- a/coderd/rbac/roles_test.go +++ b/coderd/rbac/roles_test.go @@ -35,7 +35,7 @@ func (a authSubject) Subjects() []authSubject { return []authSubject{a} } func TestBuiltInRoles(t *testing.T) { t.Parallel() for _, r := range rbac.SiteBuiltInRoles() { - r := r + t.Run(r.Identifier.String(), func(t *testing.T) { t.Parallel() require.NoError(t, r.Valid(), "invalid role") @@ -43,7 +43,7 @@ func TestBuiltInRoles(t *testing.T) { } for _, r := range rbac.OrganizationRoles(uuid.New()) { - r := r + t.Run(r.Identifier.String(), func(t *testing.T) { t.Parallel() require.NoError(t, r.Valid(), "invalid role") @@ -885,7 +885,7 @@ func TestRolePermissions(t *testing.T) { passed := true // nolint:tparallel,paralleltest for _, c := range testCases { - c := c + // nolint:tparallel,paralleltest // These share the same remainingPermissions map t.Run(c.Name, func(t *testing.T) { remainingSubjs := make(map[string]struct{}) @@ -984,7 +984,7 @@ func TestIsOrgRole(t *testing.T) { // nolint:paralleltest for _, c := range testCases { - c := c + t.Run(c.Identifier.String(), func(t *testing.T) { t.Parallel() ok := c.Identifier.IsOrgRole() @@ -1081,7 +1081,7 @@ func TestChangeSet(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/subject_test.go b/coderd/rbac/subject_test.go index e2a2f24932c36..e23c9865a6362 100644 --- a/coderd/rbac/subject_test.go +++ b/coderd/rbac/subject_test.go @@ -119,7 +119,7 @@ func TestSubjectEqual(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/render/markdown_test.go b/coderd/render/markdown_test.go index 40f3dae137633..9a60ba1714044 100644 --- a/coderd/render/markdown_test.go +++ b/coderd/render/markdown_test.go @@ -79,7 +79,6 @@ func TestHTML(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/schedule/autostop_test.go b/coderd/schedule/autostop_test.go index 8b4fe969e59d7..a0d66371a35e8 100644 --- a/coderd/schedule/autostop_test.go +++ b/coderd/schedule/autostop_test.go @@ -486,7 +486,6 @@ func TestCalculateAutoStop(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -622,7 +621,7 @@ func TestFindWeek(t *testing.T) { } for _, tz := range timezones { - tz := tz + t.Run("Loc/"+tz, func(t *testing.T) { t.Parallel() diff --git a/coderd/schedule/cron/cron_test.go b/coderd/schedule/cron/cron_test.go index 7cf146767fab3..3db1b982faf1e 100644 --- a/coderd/schedule/cron/cron_test.go +++ b/coderd/schedule/cron/cron_test.go @@ -141,7 +141,7 @@ func Test_Weekly(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual, err := cron.Weekly(testCase.spec) diff --git a/coderd/searchquery/search_test.go b/coderd/searchquery/search_test.go index 065937f389e4a..8acdc41935fa6 100644 --- a/coderd/searchquery/search_test.go +++ b/coderd/searchquery/search_test.go @@ -267,7 +267,7 @@ func TestSearchWorkspace(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() // TODO: Replace this with the mock database. @@ -352,7 +352,7 @@ func TestSearchAudit(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() // Do not use a real database, this is only used for an @@ -520,7 +520,7 @@ func TestSearchUsers(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() values, errs := searchquery.Users(c.Query) @@ -562,7 +562,7 @@ func TestSearchTemplates(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() // Do not use a real database, this is only used for an diff --git a/coderd/tailnet_test.go b/coderd/tailnet_test.go index 28265404c3eae..495d4b97cb91f 100644 --- a/coderd/tailnet_test.go +++ b/coderd/tailnet_test.go @@ -257,7 +257,7 @@ func TestServerTailnet_ReverseProxy(t *testing.T) { port := ":4444" for i, ag := range agents { - i := i + ln, err := ag.TailnetConn().Listen("tcp", port) require.NoError(t, err) wln := &wrappedListener{Listener: ln} diff --git a/coderd/telemetry/telemetry_test.go b/coderd/telemetry/telemetry_test.go index 498f97362c15b..0ea89acd5d6c3 100644 --- a/coderd/telemetry/telemetry_test.go +++ b/coderd/telemetry/telemetry_test.go @@ -544,7 +544,7 @@ func TestRecordTelemetryStatus(t *testing.T) { {name: "Telemetry was disabled still disabled", recordedTelemetryEnabled: "false", telemetryEnabled: false, shouldReport: false}, {name: "Telemetry was disabled still disabled, invalid value", recordedTelemetryEnabled: "invalid", telemetryEnabled: false, shouldReport: false}, } { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/templateversions_test.go b/coderd/templateversions_test.go index e4027a1f14605..a9a860747a2ac 100644 --- a/coderd/templateversions_test.go +++ b/coderd/templateversions_test.go @@ -604,7 +604,7 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) { }, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) @@ -1393,7 +1393,7 @@ func TestPaginatedTemplateVersions(t *testing.T) { file, err := client.Upload(egCtx, codersdk.ContentTypeTar, bytes.NewReader(data)) require.NoError(t, err) for i := 0; i < total; i++ { - i := i + eg.Go(func() error { templateVersion, err := client.CreateTemplateVersion(egCtx, user.OrganizationID, codersdk.CreateTemplateVersionRequest{ Name: uuid.NewString(), @@ -1466,7 +1466,7 @@ func TestPaginatedTemplateVersions(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/tracing/httpmw_test.go b/coderd/tracing/httpmw_test.go index 0583b29159ee5..ecd168fa1b842 100644 --- a/coderd/tracing/httpmw_test.go +++ b/coderd/tracing/httpmw_test.go @@ -77,7 +77,6 @@ func Test_Middleware(t *testing.T) { } for _, c := range cases { - c := c name := strings.ReplaceAll(strings.TrimPrefix(c.path, "/"), "/", "_") t.Run(name, func(t *testing.T) { diff --git a/coderd/updatecheck/updatecheck_test.go b/coderd/updatecheck/updatecheck_test.go index 3e21309c5ff71..a40888a25f66e 100644 --- a/coderd/updatecheck/updatecheck_test.go +++ b/coderd/updatecheck/updatecheck_test.go @@ -112,7 +112,7 @@ func TestChecker_Latest(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/updatecheck_test.go b/coderd/updatecheck_test.go index c81dc0821a152..13e47ffc224ad 100644 --- a/coderd/updatecheck_test.go +++ b/coderd/updatecheck_test.go @@ -51,7 +51,6 @@ func TestUpdateCheck_NewVersion(t *testing.T) { }, } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/userauth_test.go b/coderd/userauth_test.go index 6d224818a6a46..b84aaa7fb8c76 100644 --- a/coderd/userauth_test.go +++ b/coderd/userauth_test.go @@ -1473,7 +1473,7 @@ func TestUserOIDC(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() opts := []oidctest.FakeIDPOpt{ diff --git a/coderd/userpassword/userpassword_test.go b/coderd/userpassword/userpassword_test.go index 41eebf49c974d..e3ad7e7e0700c 100644 --- a/coderd/userpassword/userpassword_test.go +++ b/coderd/userpassword/userpassword_test.go @@ -27,7 +27,7 @@ func TestUserPasswordValidate(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() err := userpassword.Validate(tt.password) @@ -93,7 +93,7 @@ func TestUserPasswordCompare(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() if tt.shouldHash { diff --git a/coderd/users_test.go b/coderd/users_test.go index 2e8eb5f3e842e..aef77ac33eaf9 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -1777,7 +1777,7 @@ func TestUsersFilter(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -2461,7 +2461,7 @@ func TestPaginatedUsers(t *testing.T) { eg, _ := errgroup.WithContext(ctx) // Create users for i := 0; i < total; i++ { - i := i + eg.Go(func() error { email := fmt.Sprintf("%d@coder.com", i) username := fmt.Sprintf("user%d", i) @@ -2519,7 +2519,7 @@ func TestPaginatedUsers(t *testing.T) { {name: "username search", limit: 3, allUsers: specialUsers, opt: usernameSearch}, } for _, tt := range tests { - tt := tt + t.Run(fmt.Sprintf("%s %d", tt.name, tt.limit), func(t *testing.T) { t.Parallel() diff --git a/coderd/util/maps/maps_test.go b/coderd/util/maps/maps_test.go index 543c100c210a5..655adc9c23a68 100644 --- a/coderd/util/maps/maps_test.go +++ b/coderd/util/maps/maps_test.go @@ -70,7 +70,7 @@ func TestSubset(t *testing.T) { expected: true, }, } { - tc := tc + t.Run("#"+strconv.Itoa(idx), func(t *testing.T) { t.Parallel() diff --git a/coderd/util/strings/strings_test.go b/coderd/util/strings/strings_test.go index 2db9c9e236e43..6192ad7cfd4cf 100644 --- a/coderd/util/strings/strings_test.go +++ b/coderd/util/strings/strings_test.go @@ -30,7 +30,7 @@ func TestTruncate(t *testing.T) { {"foo", 0, ""}, {"foo", -1, ""}, } { - tt := tt + t.Run(tt.expected, func(t *testing.T) { t.Parallel() actual := strings.Truncate(tt.s, tt.n) diff --git a/coderd/util/xio/limitwriter_test.go b/coderd/util/xio/limitwriter_test.go index 90d83f81e7d9e..d9b1694268525 100644 --- a/coderd/util/xio/limitwriter_test.go +++ b/coderd/util/xio/limitwriter_test.go @@ -107,7 +107,7 @@ func TestLimitWriter(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/webpush/webpush.go b/coderd/webpush/webpush.go index eb35685402c21..1587ac2875a2b 100644 --- a/coderd/webpush/webpush.go +++ b/coderd/webpush/webpush.go @@ -103,7 +103,7 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk var mu sync.Mutex var eg errgroup.Group for _, subscription := range subscriptions { - subscription := subscription + eg.Go(func() error { // TODO: Implement some retry logic here. For now, this is just a // best-effort attempt. diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 6d53bd3df1140..18e7776400d33 100644 --- a/coderd/workspaceagents_test.go +++ b/coderd/workspaceagents_test.go @@ -1065,7 +1065,7 @@ func TestWorkspaceAgentListeningPorts(t *testing.T) { }, }, } { - tc := tc + t.Run("OK_"+tc.name, func(t *testing.T) { t.Parallel() @@ -1340,7 +1340,7 @@ func TestWorkspaceAgentContainers(t *testing.T) { }, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -1692,7 +1692,7 @@ func TestWorkspaceAgent_LifecycleState(t *testing.T) { } //nolint:paralleltest // No race between setting the state and getting the workspace. for _, tt := range tests { - tt := tt + t.Run(string(tt.state), func(t *testing.T) { state, err := agentsdk.ProtoFromLifecycleState(tt.state) if tt.wantErr { diff --git a/coderd/workspaceapps/apptest/apptest.go b/coderd/workspaceapps/apptest/apptest.go index 4e48e60d2d47f..c2d2e291a913b 100644 --- a/coderd/workspaceapps/apptest/apptest.go +++ b/coderd/workspaceapps/apptest/apptest.go @@ -500,7 +500,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) { } for _, c := range cases { - c := c if c.name == "Path" && appHostIsPrimary { // Workspace application auth does not apply to path apps @@ -1686,7 +1685,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/appurl/appurl_test.go b/coderd/workspaceapps/appurl/appurl_test.go index 3924949cb30ad..a83b4ef63d3b9 100644 --- a/coderd/workspaceapps/appurl/appurl_test.go +++ b/coderd/workspaceapps/appurl/appurl_test.go @@ -56,7 +56,7 @@ func TestApplicationURLString(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -158,7 +158,7 @@ func TestParseSubdomainAppURL(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -378,7 +378,7 @@ func TestCompileHostnamePattern(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -390,7 +390,7 @@ func TestCompileHostnamePattern(t *testing.T) { require.Equal(t, expected, regex.String(), "generated regex does not match") for i, m := range c.matchCases { - m := m + t.Run(fmt.Sprintf("MatchCase%d", i), func(t *testing.T) { t.Parallel() @@ -459,7 +459,7 @@ func TestConvertAppURLForCSP(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() require.Equal(t, c.expected, appurl.ConvertAppHostForCSP(c.host, c.wildcard)) diff --git a/coderd/workspaceapps/db_test.go b/coderd/workspaceapps/db_test.go index 597d1daadfa54..0779303308c1f 100644 --- a/coderd/workspaceapps/db_test.go +++ b/coderd/workspaceapps/db_test.go @@ -270,7 +270,6 @@ func Test_ResolveRequest(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/request_test.go b/coderd/workspaceapps/request_test.go index fbabc840745e9..a09c1af1f270c 100644 --- a/coderd/workspaceapps/request_test.go +++ b/coderd/workspaceapps/request_test.go @@ -272,7 +272,7 @@ func Test_RequestValidate(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() req := c.req diff --git a/coderd/workspaceapps/stats_test.go b/coderd/workspaceapps/stats_test.go index 51a6d9eebf169..e007d80634de6 100644 --- a/coderd/workspaceapps/stats_test.go +++ b/coderd/workspaceapps/stats_test.go @@ -280,7 +280,7 @@ func TestStatsCollector(t *testing.T) { // Run tests. for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/token_test.go b/coderd/workspaceapps/token_test.go index db070268fa196..5c2f01116286c 100644 --- a/coderd/workspaceapps/token_test.go +++ b/coderd/workspaceapps/token_test.go @@ -273,7 +273,6 @@ func Test_TokenMatchesRequest(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps_test.go b/coderd/workspaceapps_test.go index 91950ac855a1f..0b8c6b02e102f 100644 --- a/coderd/workspaceapps_test.go +++ b/coderd/workspaceapps_test.go @@ -57,7 +57,7 @@ func TestGetAppHost(t *testing.T) { }, } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -182,7 +182,7 @@ func TestWorkspaceApplicationAuth(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 018dd363bdee6..09030c07b012c 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -652,7 +652,7 @@ func TestWorkspace(t *testing.T) { } for _, tc := range testCases { - tc := tc // Capture range variable + // Capture range variable t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -1802,7 +1802,7 @@ func TestWorkspaceFilter(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() workspaces, err := client.Workspaces(ctx, c.Filter) @@ -2583,7 +2583,7 @@ func TestWorkspaceUpdateAutostart(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() var ( @@ -2763,7 +2763,7 @@ func TestWorkspaceUpdateTTL(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -2864,7 +2864,6 @@ func TestWorkspaceUpdateTTL(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspacestats/activitybump_test.go b/coderd/workspacestats/activitybump_test.go index ccee299a46548..8bb33000e27c6 100644 --- a/coderd/workspacestats/activitybump_test.go +++ b/coderd/workspacestats/activitybump_test.go @@ -158,9 +158,9 @@ func Test_ActivityBumpWorkspace(t *testing.T) { expectedBump: 0, }, } { - tt := tt + for _, tz := range timezones { - tz := tz + t.Run(tt.name+"/"+tz, func(t *testing.T) { t.Parallel() nextAutostart := tt.nextAutostart diff --git a/codersdk/agentsdk/logs_test.go b/codersdk/agentsdk/logs_test.go index 2b3b934c8db3c..422d51b89aa71 100644 --- a/codersdk/agentsdk/logs_test.go +++ b/codersdk/agentsdk/logs_test.go @@ -168,7 +168,7 @@ func TestStartupLogsWriter_Write(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -253,7 +253,7 @@ func TestStartupLogsSender(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/client_internal_test.go b/codersdk/client_internal_test.go index 0650c3c32097d..7161d722c2cb5 100644 --- a/codersdk/client_internal_test.go +++ b/codersdk/client_internal_test.go @@ -76,7 +76,6 @@ func TestIsConnectionErr(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -298,7 +297,7 @@ func Test_readBodyAsError(t *testing.T) { } for _, c := range tests { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/deployment_internal_test.go b/codersdk/deployment_internal_test.go index 09ee7f2a2cc71..4ddf63f6b961d 100644 --- a/codersdk/deployment_internal_test.go +++ b/codersdk/deployment_internal_test.go @@ -28,7 +28,6 @@ func TestRemoveTrailingVersionInfo(t *testing.T) { } for _, tc := range testCases { - tc := tc stripped := removeTrailingVersionInfo(tc.Version) require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index 1d2af676596d3..603e1a7143387 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -196,7 +196,7 @@ func TestSSHConfig_ParseOptions(t *testing.T) { } for _, tt := range testCases { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() c := codersdk.SSHConfig{ @@ -277,7 +277,7 @@ func TestTimezoneOffsets(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -524,7 +524,6 @@ func TestFeatureComparison(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -619,7 +618,6 @@ func TestNotificationsCanBeDisabled(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/healthsdk/healthsdk_test.go b/codersdk/healthsdk/healthsdk_test.go index 517837e20a2de..8872b0f88d344 100644 --- a/codersdk/healthsdk/healthsdk_test.go +++ b/codersdk/healthsdk/healthsdk_test.go @@ -148,7 +148,7 @@ func TestSummarize(t *testing.T) { }, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() actual := tt.br.Summarize(tt.pfx, tt.docsURL) diff --git a/codersdk/healthsdk/interfaces_internal_test.go b/codersdk/healthsdk/interfaces_internal_test.go index f870e543166e1..3b591360dde3e 100644 --- a/codersdk/healthsdk/interfaces_internal_test.go +++ b/codersdk/healthsdk/interfaces_internal_test.go @@ -160,7 +160,7 @@ func Test_generateInterfacesReport(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() r := generateInterfacesReport(&tc.state) diff --git a/codersdk/name_test.go b/codersdk/name_test.go index 487f3778ac70e..26145bf460938 100644 --- a/codersdk/name_test.go +++ b/codersdk/name_test.go @@ -60,7 +60,7 @@ func TestUsernameValid(t *testing.T) { {"123456789012345678901234567890123123456789012345678901234567890123", false}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Username, func(t *testing.T) { t.Parallel() valid := codersdk.NameValid(testCase.Username) @@ -115,7 +115,7 @@ func TestTemplateDisplayNameValid(t *testing.T) { {"12345678901234567890123456789012345678901234567890123456789012345", false}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() valid := codersdk.DisplayNameValid(testCase.Name) @@ -156,7 +156,7 @@ func TestTemplateVersionNameValid(t *testing.T) { {"!!!!1 ?????", false}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() valid := codersdk.TemplateVersionNameValid(testCase.Name) @@ -197,7 +197,7 @@ func TestFrom(t *testing.T) { {"", ""}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.From, func(t *testing.T) { t.Parallel() converted := codersdk.UsernameFrom(testCase.From) @@ -243,7 +243,7 @@ func TestUserRealNameValid(t *testing.T) { {strings.Repeat("a", 129), false}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() err := codersdk.UserRealNameValid(testCase.Name) @@ -277,7 +277,7 @@ func TestGroupNameValid(t *testing.T) { {random256String, false}, } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() err := codersdk.GroupNameValid(testCase.Name) diff --git a/codersdk/pagination_test.go b/codersdk/pagination_test.go index 53a3fcaebceb4..1dbc2400e4f8d 100644 --- a/codersdk/pagination_test.go +++ b/codersdk/pagination_test.go @@ -42,7 +42,7 @@ func TestPagination_asRequestOption(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/richparameters_test.go b/codersdk/richparameters_test.go index 5635a82beb6c6..fac86e54404e7 100644 --- a/codersdk/richparameters_test.go +++ b/codersdk/richparameters_test.go @@ -322,7 +322,7 @@ func TestRichParameterValidation(t *testing.T) { } for _, tc := range tests { - tc := tc + t.Run(tc.parameterName+"-"+tc.value, func(t *testing.T) { t.Parallel() diff --git a/codersdk/time_test.go b/codersdk/time_test.go index a2d3b20622ba7..0741a006e6653 100644 --- a/codersdk/time_test.go +++ b/codersdk/time_test.go @@ -47,7 +47,7 @@ func TestNullTime_MarshalJSON(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -104,7 +104,7 @@ func TestNullTime_UnmarshalJSON(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -145,7 +145,7 @@ func TestNullTime_IsZero(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/workspacedisplaystatus_internal_test.go b/codersdk/workspacedisplaystatus_internal_test.go index 2b910c89835fb..31767dabfe2f5 100644 --- a/codersdk/workspacedisplaystatus_internal_test.go +++ b/codersdk/workspacedisplaystatus_internal_test.go @@ -90,7 +90,7 @@ func TestWorkspaceDisplayStatus(t *testing.T) { }, } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := WorkspaceDisplayStatus(tt.jobStatus, tt.transition); got != tt.want { diff --git a/cryptorand/strings_test.go b/cryptorand/strings_test.go index 8557667457a6c..6fce5752d68f3 100644 --- a/cryptorand/strings_test.go +++ b/cryptorand/strings_test.go @@ -92,7 +92,7 @@ func TestStringCharset(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/audit/audit_test.go b/enterprise/audit/audit_test.go index 6d825306c3346..5c44d40768307 100644 --- a/enterprise/audit/audit_test.go +++ b/enterprise/audit/audit_test.go @@ -84,7 +84,7 @@ func TestAuditor(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/audit/diff_internal_test.go b/enterprise/audit/diff_internal_test.go index d5c191c8907fa..c946019c205ee 100644 --- a/enterprise/audit/diff_internal_test.go +++ b/enterprise/audit/diff_internal_test.go @@ -417,7 +417,7 @@ func runDiffTests(t *testing.T, tests []diffTest) { t.Helper() for _, test := range tests { - test := test + typName := reflect.TypeOf(test.left).Name() t.Run(typName+"/"+test.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/cli/start_test.go b/enterprise/cli/start_test.go index dd86b20d44fb6..d442742d96c6d 100644 --- a/enterprise/cli/start_test.go +++ b/enterprise/cli/start_test.go @@ -121,11 +121,11 @@ func TestStart(t *testing.T) { } for _, cmd := range []string{"start", "restart"} { - cmd := cmd + t.Run(cmd, func(t *testing.T) { t.Parallel() for _, c := range cases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/authorize_test.go b/enterprise/coderd/authorize_test.go index 670df18916aaa..1d3fec95c3040 100644 --- a/enterprise/coderd/authorize_test.go +++ b/enterprise/coderd/authorize_test.go @@ -96,7 +96,6 @@ func TestCheckACLPermissions(t *testing.T) { } for _, c := range testCases { - c := c t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/coderd_test.go b/enterprise/coderd/coderd_test.go index 446fce042d70f..dccb0028cfdf6 100644 --- a/enterprise/coderd/coderd_test.go +++ b/enterprise/coderd/coderd_test.go @@ -292,7 +292,6 @@ func TestEntitlements_Prebuilds(t *testing.T) { } for _, tc := range cases { - tc := tc t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -618,7 +617,7 @@ func TestSCIMDisabled(t *testing.T) { } for _, p := range checkPaths { - p := p + t.Run(p, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/enidpsync/organizations_test.go b/enterprise/coderd/enidpsync/organizations_test.go index b2e120592b582..5372b1329bf1c 100644 --- a/enterprise/coderd/enidpsync/organizations_test.go +++ b/enterprise/coderd/enidpsync/organizations_test.go @@ -296,7 +296,7 @@ func TestOrganizationSync(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitMedium) diff --git a/enterprise/coderd/httpmw/provisionerdaemon_test.go b/enterprise/coderd/httpmw/provisionerdaemon_test.go index 84da7f546fa35..c7ff5bad357aa 100644 --- a/enterprise/coderd/httpmw/provisionerdaemon_test.go +++ b/enterprise/coderd/httpmw/provisionerdaemon_test.go @@ -126,7 +126,7 @@ func TestExtractProvisionerDaemonAuthenticated(t *testing.T) { } for _, test := range tests { - test := test + t.Run(test.name, func(t *testing.T) { t.Parallel() routeCtx := chi.NewRouteContext() diff --git a/enterprise/coderd/insights_test.go b/enterprise/coderd/insights_test.go index 044c5988eb036..ae890a21db868 100644 --- a/enterprise/coderd/insights_test.go +++ b/enterprise/coderd/insights_test.go @@ -34,7 +34,7 @@ func TestTemplateInsightsWithTemplateAdminACL(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) { t.Parallel() @@ -94,7 +94,7 @@ func TestTemplateInsightsWithRole(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(fmt.Sprintf("with interval=%q role=%q", tt.interval, tt.role), func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/license/license_test.go b/enterprise/coderd/license/license_test.go index 184a611c40949..9ef12aa58f88e 100644 --- a/enterprise/coderd/license/license_test.go +++ b/enterprise/coderd/license/license_test.go @@ -848,7 +848,6 @@ func TestLicenseEntitlements(t *testing.T) { } for _, tc := range testCases { - tc := tc t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/claim_test.go b/enterprise/coderd/prebuilds/claim_test.go index 83933f3a98cd3..c255490379427 100644 --- a/enterprise/coderd/prebuilds/claim_test.go +++ b/enterprise/coderd/prebuilds/claim_test.go @@ -128,7 +128,7 @@ func TestClaimPrebuild(t *testing.T) { for name, tc := range cases { // Ensure that prebuilt workspaces can be claimed in non-default organizations: for _, useDefaultOrg := range []bool{true, false} { - tc := tc + t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/membership_test.go b/enterprise/coderd/prebuilds/membership_test.go index 6caa7178d9d60..c11de4c03345b 100644 --- a/enterprise/coderd/prebuilds/membership_test.go +++ b/enterprise/coderd/prebuilds/membership_test.go @@ -57,7 +57,7 @@ func TestReconcileAll(t *testing.T) { } for _, tc := range tests { - tc := tc // capture + // capture t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/metricscollector_test.go b/enterprise/coderd/prebuilds/metricscollector_test.go index dce9e07dd110f..7f37a59880f4d 100644 --- a/enterprise/coderd/prebuilds/metricscollector_test.go +++ b/enterprise/coderd/prebuilds/metricscollector_test.go @@ -177,19 +177,19 @@ func TestMetricsCollector(t *testing.T) { }, } for _, test := range tests { - test := test // capture for parallel + // capture for parallel for _, transition := range test.transitions { - transition := transition // capture for parallel + // capture for parallel for _, jobStatus := range test.jobStatuses { - jobStatus := jobStatus // capture for parallel + // capture for parallel for _, initiatorID := range test.initiatorIDs { - initiatorID := initiatorID // capture for parallel + // capture for parallel for _, ownerID := range test.ownerIDs { - ownerID := ownerID // capture for parallel + // capture for parallel for _, templateDeleted := range test.templateDeleted { - templateDeleted := templateDeleted // capture for parallel + // capture for parallel for _, eligible := range test.eligible { - eligible := eligible // capture for parallel + // capture for parallel t.Run(fmt.Sprintf("%v/transition:%s/jobStatus:%s", test.name, transition, jobStatus), func(t *testing.T) { t.Parallel() @@ -260,7 +260,7 @@ func TestMetricsCollector(t *testing.T) { require.Equal(t, 1, len(presets)) for _, preset := range presets { - preset := preset // capture for parallel + // capture for parallel labels := map[string]string{ "template_name": template.Name, "preset_name": preset.Name, diff --git a/enterprise/coderd/prebuilds/reconcile_test.go b/enterprise/coderd/prebuilds/reconcile_test.go index 51e26c0c29cea..ce866a81f5d8b 100644 --- a/enterprise/coderd/prebuilds/reconcile_test.go +++ b/enterprise/coderd/prebuilds/reconcile_test.go @@ -309,7 +309,7 @@ func TestPrebuildReconciliation(t *testing.T) { }, } for _, tc := range testCases { - tc := tc // capture for parallel + // capture for parallel for _, templateVersionActive := range tc.templateVersionActive { for _, prebuildLatestTransition := range tc.prebuildLatestTransitions { for _, prebuildJobStatus := range tc.prebuildJobStatuses { diff --git a/enterprise/coderd/provisionerdaemons_test.go b/enterprise/coderd/provisionerdaemons_test.go index cdc6267d90971..85c7e62d0ac4c 100644 --- a/enterprise/coderd/provisionerdaemons_test.go +++ b/enterprise/coderd/provisionerdaemons_test.go @@ -921,7 +921,7 @@ func TestGetProvisionerDaemons(t *testing.T) { }, } for _, tt := range testCases { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() dv := coderdtest.DeploymentValues(t) diff --git a/enterprise/coderd/provisionerkeys_test.go b/enterprise/coderd/provisionerkeys_test.go index e3f5839bf8b02..97e4eccf1fa63 100644 --- a/enterprise/coderd/provisionerkeys_test.go +++ b/enterprise/coderd/provisionerkeys_test.go @@ -167,7 +167,7 @@ func TestGetProvisionerKey(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/proxyhealth/proxyhealth.go b/enterprise/coderd/proxyhealth/proxyhealth.go index 7faac6a9e8147..0b6f3ed666939 100644 --- a/enterprise/coderd/proxyhealth/proxyhealth.go +++ b/enterprise/coderd/proxyhealth/proxyhealth.go @@ -240,7 +240,7 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID } // Each proxy needs to have a status set. Make a local copy for the // call to be run async. - proxy := proxy + status := ProxyStatus{ Proxy: proxy, CheckedAt: now, diff --git a/enterprise/coderd/roles_test.go b/enterprise/coderd/roles_test.go index 57b66a368248c..82bc5e0c8329f 100644 --- a/enterprise/coderd/roles_test.go +++ b/enterprise/coderd/roles_test.go @@ -517,7 +517,7 @@ func TestListRoles(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/schedule/template_test.go b/enterprise/coderd/schedule/template_test.go index 712fa032c8c1b..c400f85ff69bc 100644 --- a/enterprise/coderd/schedule/template_test.go +++ b/enterprise/coderd/schedule/template_test.go @@ -191,7 +191,6 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -778,7 +777,6 @@ func TestTemplateTTL(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/templates_test.go b/enterprise/coderd/templates_test.go index b6c2048190e9a..8cb972e847ef7 100644 --- a/enterprise/coderd/templates_test.go +++ b/enterprise/coderd/templates_test.go @@ -470,7 +470,6 @@ func TestTemplates(t *testing.T) { } for _, c := range cases { - c := c // nolint: paralleltest // context is from parent t.Run t.Run(c.Name, func(t *testing.T) { diff --git a/enterprise/coderd/userauth_test.go b/enterprise/coderd/userauth_test.go index 267e1168f84cf..e6166bc847977 100644 --- a/enterprise/coderd/userauth_test.go +++ b/enterprise/coderd/userauth_test.go @@ -902,7 +902,7 @@ func TestGroupSync(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() runner := setupOIDCTest(t, oidcTestConfig{ diff --git a/enterprise/coderd/users_test.go b/enterprise/coderd/users_test.go index 5aa1ab1e8215c..aacafef72ef8a 100644 --- a/enterprise/coderd/users_test.go +++ b/enterprise/coderd/users_test.go @@ -426,7 +426,7 @@ func TestGrantSiteRoles(t *testing.T) { } for _, c := range testCases { - c := c + t.Run(c.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) diff --git a/enterprise/coderd/workspaceproxy_internal_test.go b/enterprise/coderd/workspaceproxy_internal_test.go index 9654e0ecc3e2f..5e202d53dd0bb 100644 --- a/enterprise/coderd/workspaceproxy_internal_test.go +++ b/enterprise/coderd/workspaceproxy_internal_test.go @@ -47,7 +47,7 @@ func Test_validateProxyURL(t *testing.T) { } for _, tt := range testcases { - tt := tt + t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/workspaces_test.go b/enterprise/coderd/workspaces_test.go index ce86151f9b883..1334ac1d80c10 100644 --- a/enterprise/coderd/workspaces_test.go +++ b/enterprise/coderd/workspaces_test.go @@ -1953,7 +1953,7 @@ func TestWorkspaceTagsTerraform(t *testing.T) { }`, }, } { - tc := tc + t.Run(tc.name, func(t *testing.T) { client, owner := coderdenttest.New(t, &coderdenttest.Options{ Options: &coderdtest.Options{ diff --git a/enterprise/provisionerd/remoteprovisioners_test.go b/enterprise/provisionerd/remoteprovisioners_test.go index 5d0de5ae396b7..5360fe4e442c2 100644 --- a/enterprise/provisionerd/remoteprovisioners_test.go +++ b/enterprise/provisionerd/remoteprovisioners_test.go @@ -33,7 +33,7 @@ func TestRemoteConnector_Mainline(t *testing.T) { {name: "Smokescreen", smokescreen: true}, } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) diff --git a/enterprise/replicasync/replicasync.go b/enterprise/replicasync/replicasync.go index 0a60ccfd0a1fc..bf60740b7050f 100644 --- a/enterprise/replicasync/replicasync.go +++ b/enterprise/replicasync/replicasync.go @@ -410,7 +410,7 @@ func (m *Manager) AllPrimary() []database.Replica { // When we assign the non-pointer to a // variable it loses the reference. - replica := replica + replicas = append(replicas, replica) } return replicas diff --git a/enterprise/wsproxy/wsproxy_test.go b/enterprise/wsproxy/wsproxy_test.go index 65de627a1fb06..bcffb642410a2 100644 --- a/enterprise/wsproxy/wsproxy_test.go +++ b/enterprise/wsproxy/wsproxy_test.go @@ -282,7 +282,7 @@ resourceLoop: // Connect to each region. for _, r := range connInfo.DERPMap.Regions { - r := r + if len(r.Nodes) == 1 && r.Nodes[0].STUNOnly { // Skip STUN-only regions. continue @@ -654,7 +654,7 @@ func TestWorkspaceProxyDERPMeshProbe(t *testing.T) { replicaPingDone = [count]bool{} ) for i := range proxies { - i := i + proxies[i] = coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ Name: "proxy-1", Token: sessionToken, diff --git a/examples/examples_test.go b/examples/examples_test.go index 1a558b6506c73..f279b063f9934 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -19,7 +19,7 @@ func TestTemplate(t *testing.T) { require.NoError(t, err, "error listing examples, run \"make gen\" to ensure examples are up to date") require.NotEmpty(t, list) for _, eg := range list { - eg := eg + t.Run(eg.ID, func(t *testing.T) { t.Parallel() assert.NotEmpty(t, eg.ID, "example ID should not be empty") diff --git a/helm/coder/tests/chart_test.go b/helm/coder/tests/chart_test.go index 638b9e5005d6f..f1d3b19852137 100644 --- a/helm/coder/tests/chart_test.go +++ b/helm/coder/tests/chart_test.go @@ -163,10 +163,9 @@ func TestRenderChart(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - tc := tc for _, ns := range namespaces { - tc := tc + tc.namespace = ns t.Run(tc.namespace+"/"+tc.name, func(t *testing.T) { @@ -213,14 +212,14 @@ func TestUpdateGoldenFiles(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - tc := tc + if tc.expectedError != "" { t.Logf("skipping test case %q with render error", tc.name) continue } for _, ns := range namespaces { - tc := tc + tc.namespace = ns valuesPath := tc.valuesFilePath() diff --git a/helm/provisioner/tests/chart_test.go b/helm/provisioner/tests/chart_test.go index a6f3ba7370bac..ffc841c98b3d8 100644 --- a/helm/provisioner/tests/chart_test.go +++ b/helm/provisioner/tests/chart_test.go @@ -141,9 +141,9 @@ func TestRenderChart(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - tc := tc + for _, ns := range namespaces { - tc := tc + tc.namespace = ns t.Run(tc.namespace+"/"+tc.name, func(t *testing.T) { @@ -190,14 +190,14 @@ func TestUpdateGoldenFiles(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - tc := tc + if tc.expectedError != "" { t.Logf("skipping test case %q with render error", tc.name) continue } for _, ns := range namespaces { - tc := tc + tc.namespace = ns valuesPath := tc.valuesFilePath() diff --git a/provisioner/terraform/diagnostic_test.go b/provisioner/terraform/diagnostic_test.go index 8727256b75376..2cd76b0eca97c 100644 --- a/provisioner/terraform/diagnostic_test.go +++ b/provisioner/terraform/diagnostic_test.go @@ -47,7 +47,6 @@ func TestFormatDiagnostic(t *testing.T) { } for name, tc := range tests { - tc := tc t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/executor_internal_test.go b/provisioner/terraform/executor_internal_test.go index 97cb5285372f2..90e85a5bf339a 100644 --- a/provisioner/terraform/executor_internal_test.go +++ b/provisioner/terraform/executor_internal_test.go @@ -157,7 +157,6 @@ func TestOnlyDataResources(t *testing.T) { } for _, tt := range tests { - tt := tt t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/parse_test.go b/provisioner/terraform/parse_test.go index 7d176cb886469..c83335d13da63 100644 --- a/provisioner/terraform/parse_test.go +++ b/provisioner/terraform/parse_test.go @@ -376,7 +376,7 @@ func TestParse(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/provision_test.go b/provisioner/terraform/provision_test.go index 505fd2df41400..48e8c1e198910 100644 --- a/provisioner/terraform/provision_test.go +++ b/provisioner/terraform/provision_test.go @@ -312,7 +312,7 @@ func TestProvision_Cancel(t *testing.T) { }, } for _, tt := range tests { - tt := tt + // below we exec fake_cancel.sh, which causes the kernel to execute it, and if more than // one process tries to do this, it can cause "text file busy" // nolint: paralleltest @@ -1067,7 +1067,7 @@ func TestProvision(t *testing.T) { } for _, testCase := range testCases { - testCase := testCase + t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/resources_test.go b/provisioner/terraform/resources_test.go index e58f5c039f9e4..f202e157751e9 100644 --- a/provisioner/terraform/resources_test.go +++ b/provisioner/terraform/resources_test.go @@ -917,8 +917,7 @@ func TestConvertResources(t *testing.T) { }, }, } { - folderName := folderName - expected := expected + t.Run(folderName, func(t *testing.T) { t.Parallel() dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", folderName) @@ -1101,7 +1100,7 @@ func TestAppSlugValidation(t *testing.T) { //nolint:paralleltest for i, c := range cases { - c := c + t.Run(fmt.Sprintf("case-%d", i), func(t *testing.T) { // Change the first app slug to match the current case. for _, resource := range tfPlan.PlannedValues.RootModule.Resources { @@ -1178,7 +1177,7 @@ func TestAgentNameInvalid(t *testing.T) { //nolint:paralleltest for i, c := range cases { - c := c + t.Run(fmt.Sprintf("case-%d", i), func(t *testing.T) { // Change the first agent name to match the current case. for _, resource := range tfPlan.PlannedValues.RootModule.Resources { @@ -1330,7 +1329,7 @@ func TestInstanceTypeAssociation(t *testing.T) { ResourceType: "azurerm_windows_virtual_machine", InstanceTypeKey: "size", }} { - tc := tc + t.Run(tc.ResourceType, func(t *testing.T) { t.Parallel() ctx, logger := ctxAndLogger(t) @@ -1389,7 +1388,7 @@ func TestInstanceIDAssociation(t *testing.T) { ResourceType: "azurerm_windows_virtual_machine", InstanceIDKey: "virtual_machine_id", }} { - tc := tc + t.Run(tc.ResourceType, func(t *testing.T) { t.Parallel() ctx, logger := ctxAndLogger(t) diff --git a/provisioner/terraform/tfparse/tfparse_test.go b/provisioner/terraform/tfparse/tfparse_test.go index ceefc484b2169..506778027efdd 100644 --- a/provisioner/terraform/tfparse/tfparse_test.go +++ b/provisioner/terraform/tfparse/tfparse_test.go @@ -587,7 +587,7 @@ func Test_WorkspaceTagDefaultsFromFile(t *testing.T) { expectTags: map[string]string{"foo": "bar", "a": "1"}, }, } { - tc := tc + t.Run(tc.name+"/tar", func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/provisionersdk/provisionertags_test.go b/provisionersdk/provisionertags_test.go index 70e05473eecc0..e91f264a5745b 100644 --- a/provisionersdk/provisionertags_test.go +++ b/provisionersdk/provisionertags_test.go @@ -185,7 +185,7 @@ func TestMutateTags(t *testing.T) { }, }, } { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() got := provisionersdk.MutateTags(tt.userID, tt.tags...) diff --git a/pty/ptytest/ptytest_test.go b/pty/ptytest/ptytest_test.go index 2b1b5570b18ea..16c7d4ed924df 100644 --- a/pty/ptytest/ptytest_test.go +++ b/pty/ptytest/ptytest_test.go @@ -56,7 +56,7 @@ func TestPtytest(t *testing.T) { {name: "10241 large output", output: strings.Repeat(".", 10241)}, // 1024 * 10 + 1 } for _, tt := range tests { - tt := tt + // nolint:paralleltest // Avoid parallel test to more easily identify the issue. t.Run(tt.name, func(t *testing.T) { cmd := &serpent.Command{ diff --git a/scaletest/agentconn/config_test.go b/scaletest/agentconn/config_test.go index 5f5cdf7c53da7..456d300a442e2 100644 --- a/scaletest/agentconn/config_test.go +++ b/scaletest/agentconn/config_test.go @@ -167,7 +167,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/createworkspaces/config_test.go b/scaletest/createworkspaces/config_test.go index 6a3d9e8104624..86c0016dd9830 100644 --- a/scaletest/createworkspaces/config_test.go +++ b/scaletest/createworkspaces/config_test.go @@ -63,7 +63,6 @@ func Test_UserConfig(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -177,7 +176,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/harness/strategies.go b/scaletest/harness/strategies.go index 24bb04e871880..4892398e9dbe6 100644 --- a/scaletest/harness/strategies.go +++ b/scaletest/harness/strategies.go @@ -122,7 +122,7 @@ var _ ExecutionStrategy = TimeoutExecutionStrategyWrapper{} func (t TimeoutExecutionStrategyWrapper) Run(ctx context.Context, fns []TestFn) ([]error, error) { newFns := make([]TestFn, len(fns)) for i, fn := range fns { - fn := fn + newFns[i] = func(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, t.Timeout) defer cancel() diff --git a/scaletest/harness/strategies_test.go b/scaletest/harness/strategies_test.go index 0858b5bf71da1..691b20bcc13eb 100644 --- a/scaletest/harness/strategies_test.go +++ b/scaletest/harness/strategies_test.go @@ -186,7 +186,6 @@ func strategyTestData(count int, runFn func(ctx context.Context, i int, logs io. fns = make([]harness.TestFn, count) ) for i := 0; i < count; i++ { - i := i runs[i] = harness.NewTestRun("test", strconv.Itoa(i), testFns{ RunFn: func(ctx context.Context, id string, logs io.Writer) error { diff --git a/scaletest/placebo/config_test.go b/scaletest/placebo/config_test.go index 8e3a40000a02e..b0bd82a4658a8 100644 --- a/scaletest/placebo/config_test.go +++ b/scaletest/placebo/config_test.go @@ -98,7 +98,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/reconnectingpty/config_test.go b/scaletest/reconnectingpty/config_test.go index e0712b4631097..76822046b5418 100644 --- a/scaletest/reconnectingpty/config_test.go +++ b/scaletest/reconnectingpty/config_test.go @@ -61,7 +61,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/workspacebuild/config_test.go b/scaletest/workspacebuild/config_test.go index b9c427f104f3d..268e152d831e0 100644 --- a/scaletest/workspacebuild/config_test.go +++ b/scaletest/workspacebuild/config_test.go @@ -78,7 +78,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - c := c t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scripts/apitypings/main_test.go b/scripts/apitypings/main_test.go index 0ac20363327c3..e515fffff7f50 100644 --- a/scripts/apitypings/main_test.go +++ b/scripts/apitypings/main_test.go @@ -31,7 +31,7 @@ func TestGeneration(t *testing.T) { // Only test directories continue } - f := f + t.Run(f.Name(), func(t *testing.T) { t.Parallel() dir := filepath.Join(".", "testdata", f.Name()) diff --git a/scripts/release/main_internal_test.go b/scripts/release/main_internal_test.go index ce83e7169a35b..3557673b3ab66 100644 --- a/scripts/release/main_internal_test.go +++ b/scripts/release/main_internal_test.go @@ -115,7 +115,7 @@ Enjoy. } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() if diff := cmp.Diff(removeMainlineBlurb(tt.body), tt.want); diff != "" { @@ -167,7 +167,7 @@ func Test_release_autoversion(t *testing.T) { require.NoError(t, err) for _, file := range files { - file := file + t.Run(file, func(t *testing.T) { t.Parallel() diff --git a/scripts/releasemigrations/main.go b/scripts/releasemigrations/main.go index a06be904b004d..cc924565231b4 100644 --- a/scripts/releasemigrations/main.go +++ b/scripts/releasemigrations/main.go @@ -230,7 +230,7 @@ func hasMigrationDiff(dir string, a, b string) ([]string, error) { migrations := strings.Split(strings.TrimSpace(string(output)), "\n") filtered := make([]string, 0, len(migrations)) for _, migration := range migrations { - migration := migration + if strings.Contains(migration, "fixtures") { continue } diff --git a/scripts/typegen/main.go b/scripts/typegen/main.go index 0e7457406102e..8a94d4ff447df 100644 --- a/scripts/typegen/main.go +++ b/scripts/typegen/main.go @@ -243,7 +243,7 @@ func generateRbacObjects(templateSource string) ([]byte, error) { var out bytes.Buffer list := make([]Definition, 0) for t, v := range policy.RBACPermissions { - v := v + list = append(list, Definition{ PermissionDefinition: v, Type: t, diff --git a/site/site.go b/site/site.go index 2b64d3cf98f81..10639977ecfb3 100644 --- a/site/site.go +++ b/site/site.go @@ -823,8 +823,7 @@ func verifyBinSha1IsCurrent(dest string, siteFS fs.FS, shaFiles map[string]strin // Verify the hash of each on-disk binary. for file, hash1 := range shaFiles { - file := file - hash1 := hash1 + eg.Go(func() error { hash2, err := sha1HashFile(filepath.Join(dest, file)) if err != nil { diff --git a/site/site_test.go b/site/site_test.go index d257bd9519b3d..4dfd97aaa3a26 100644 --- a/site/site_test.go +++ b/site/site_test.go @@ -498,7 +498,7 @@ func TestServingBin(t *testing.T) { } //nolint // Parallel test detection issue. for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/tailnet/configmaps_internal_test.go b/tailnet/configmaps_internal_test.go index fa027ffc7fdd4..b9d424287a566 100644 --- a/tailnet/configmaps_internal_test.go +++ b/tailnet/configmaps_internal_test.go @@ -1116,7 +1116,7 @@ func TestConfigMaps_updatePeers_nonexist(t *testing.T) { proto.CoordinateResponse_PeerUpdate_DISCONNECTED, proto.CoordinateResponse_PeerUpdate_LOST, } { - k := k + t.Run(k.String(), func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/tailnet/convert_test.go b/tailnet/convert_test.go index 31b5794414ff3..2d1eb5569f891 100644 --- a/tailnet/convert_test.go +++ b/tailnet/convert_test.go @@ -64,7 +64,7 @@ func TestNode(t *testing.T) { } for _, tc := range testCases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() p, err := tailnet.NodeToProto(&tc.node) diff --git a/tailnet/telemetry_internal_test.go b/tailnet/telemetry_internal_test.go index c738ddb3314a8..2d23b72e83faf 100644 --- a/tailnet/telemetry_internal_test.go +++ b/tailnet/telemetry_internal_test.go @@ -121,7 +121,7 @@ func TestTelemetryStore(t *testing.T) { } for _, c := range cases { - c := c + t.Run(c.name, func(t *testing.T) { t.Parallel() telemetry, err := newTelemetryStore() diff --git a/vpn/tunnel_internal_test.go b/vpn/tunnel_internal_test.go index 5c4e6ec03d47f..ab3a6c55da43d 100644 --- a/vpn/tunnel_internal_test.go +++ b/vpn/tunnel_internal_test.go @@ -1153,7 +1153,7 @@ func TestProcessFreshState(t *testing.T) { } for _, tt := range tests { - tt := tt + t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/vpn/version_test.go b/vpn/version_test.go index cff333f10b507..8b6e366e1f632 100644 --- a/vpn/version_test.go +++ b/vpn/version_test.go @@ -175,7 +175,7 @@ func TestRPCVersionListParseString(t *testing.T) { } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() got, err := vpn.ParseRPCVersionList(tc.input) @@ -248,7 +248,7 @@ func TestRPCVersionListValidate(t *testing.T) { } for _, tc := range cases { - tc := tc + t.Run(tc.name, func(t *testing.T) { t.Parallel() err := tc.list.Validate() From bf077d331edf0a638a5f27ec25a02453bcdcc29b Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 18 Jun 2025 21:52:53 +0000 Subject: [PATCH 2/4] fix claude nonsense --- agent/agent.go | 1 - agent/agent_test.go | 11 ----------- agent/agentcontainers/containers_internal_test.go | 4 ---- agent/agentscripts/agentscripts.go | 1 - agent/agentssh/x11_internal_test.go | 1 - agent/proto/compare_test.go | 1 - agent/proto/resourcesmonitor/queue_test.go | 1 - .../resourcesmonitor/resources_monitor_test.go | 1 - apiversion/apiversion_test.go | 1 - buildinfo/buildinfo_test.go | 1 - cli/agent_internal_test.go | 1 - cli/autoupdate_test.go | 1 - cli/clitest/golden.go | 1 - cli/cliui/agent_test.go | 3 --- cli/cliui/provisionerjob_test.go | 1 - cli/cliui/resources_internal_test.go | 1 - cli/cliui/table_test.go | 1 - cli/cliutil/levenshtein/levenshtein_test.go | 2 -- cli/cliutil/provisionerwarn_test.go | 1 - cli/configssh_internal_test.go | 5 ----- cli/configssh_test.go | 1 - cli/exp_errors_test.go | 1 - cli/gitauth/askpass_test.go | 1 - cli/notifications_test.go | 1 - cli/open_internal_test.go | 2 -- cli/open_test.go | 4 ---- cli/organizationroles.go | 1 - cli/organizationsettings.go | 2 -- cli/portforward_internal_test.go | 1 - cli/portforward_test.go | 1 - cli/provisionerjobs_test.go | 1 - cli/root_internal_test.go | 1 - cli/schedule_internal_test.go | 1 - cli/schedule_test.go | 1 - cli/server.go | 2 -- cli/server_internal_test.go | 5 ----- cli/server_test.go | 3 --- cli/ssh_test.go | 2 -- cli/start_test.go | 1 - cli/templateedit_test.go | 2 -- cli/templatepull_test.go | 1 - cli/templatepush_test.go | 1 - cli/util_internal_test.go | 2 -- cli/version_test.go | 1 - cli/vpndaemon_windows_test.go | 1 - coderd/agentapi/manifest_internal_test.go | 1 - coderd/agentapi/resources_monitoring_test.go | 2 -- coderd/agentmetrics/labels_test.go | 1 - coderd/apikey/apikey_test.go | 1 - coderd/audit_test.go | 1 - coderd/authorize_test.go | 1 - .../autobuild/lifecycle_executor_internal_test.go | 1 - coderd/autobuild/lifecycle_executor_test.go | 1 - coderd/autobuild/notify/notifier_test.go | 1 - coderd/azureidentity/azureidentity_test.go | 1 - coderd/coderd_internal_test.go | 1 - coderd/database/db2sdk/db2sdk_test.go | 1 - coderd/database/dbauthz/customroles_test.go | 2 -- coderd/database/dbauthz/groupsauth_test.go | 1 - coderd/database/dbauthz/setup_test.go | 1 - coderd/database/dbmem/dbmem.go | 4 ---- coderd/database/dbmem/dbmem_test.go | 1 - coderd/database/migrations/migrate_test.go | 1 - coderd/database/pubsub/pubsub_memory.go | 1 - coderd/database/querier_test.go | 8 -------- coderd/devtunnel/tunnel_test.go | 1 - coderd/externalauth/externalauth.go | 1 - coderd/externalauth/externalauth_internal_test.go | 2 -- coderd/externalauth/externalauth_test.go | 1 - coderd/healthcheck/health/model_test.go | 1 - coderd/healthcheck/healthcheck_test.go | 1 - coderd/healthcheck/provisioner_test.go | 1 - coderd/healthcheck/workspaceproxy_internal_test.go | 2 -- coderd/healthcheck/workspaceproxy_test.go | 1 - coderd/httpapi/cookie_test.go | 1 - coderd/httpapi/json_test.go | 3 --- coderd/httpmw/authorize_test.go | 1 - coderd/httpmw/cors_test.go | 1 - coderd/httpmw/csrf_test.go | 1 - coderd/httpmw/hsts_test.go | 1 - coderd/httpmw/loggermw/logger_internal_test.go | 1 - coderd/httpmw/patternmatcher/routepatterns_test.go | 1 - coderd/httpmw/realip_test.go | 6 ------ coderd/httpmw/recover_test.go | 1 - coderd/httpmw/workspaceparam_test.go | 1 - coderd/idpsync/group.go | 3 --- coderd/idpsync/group_test.go | 4 ---- coderd/idpsync/idpsync_test.go | 1 - coderd/idpsync/role_test.go | 2 -- coderd/inboxnotifications_internal_test.go | 1 - coderd/inboxnotifications_test.go | 2 -- coderd/insights_internal_test.go | 3 --- coderd/insights_test.go | 13 ------------- coderd/jobreaper/detector_test.go | 1 - coderd/jwtutils/jwt_test.go | 2 -- coderd/metricscache/metricscache_test.go | 1 - coderd/notifications/dispatch/inbox_test.go | 1 - coderd/notifications/notifications_test.go | 2 -- coderd/notifications/render/gotmpl_test.go | 2 -- coderd/oauth2_test.go | 4 ---- coderd/pagination_internal_test.go | 1 - coderd/prebuilds/preset_snapshot_test.go | 2 -- coderd/presets_test.go | 1 - coderd/prometheusmetrics/aggregator_test.go | 1 - .../prometheusmetrics_internal_test.go | 1 - coderd/prometheusmetrics/prometheusmetrics_test.go | 5 ----- coderd/promoauth/oauth2_test.go | 1 - coderd/provisionerdserver/acquirer_test.go | 1 - .../provisionerdserver/provisionerdserver_test.go | 5 ----- coderd/provisionerjobs_internal_test.go | 1 - coderd/rbac/authz.go | 1 - coderd/rbac/authz_internal_test.go | 2 -- coderd/rbac/object_test.go | 1 - coderd/rbac/regosql/compile_test.go | 1 - coderd/rbac/regosql/sqltypes/equality_test.go | 1 - coderd/rbac/regosql/sqltypes/member_test.go | 1 - coderd/rbac/roles.go | 1 - coderd/rbac/roles_internal_test.go | 1 - coderd/rbac/roles_test.go | 5 ----- coderd/rbac/subject_test.go | 1 - coderd/render/markdown_test.go | 1 - coderd/schedule/autostop_test.go | 2 -- coderd/schedule/cron/cron_test.go | 1 - coderd/searchquery/search_test.go | 4 ---- coderd/tailnet_test.go | 1 - coderd/telemetry/telemetry_test.go | 1 - coderd/templateversions_test.go | 3 --- coderd/tracing/httpmw_test.go | 1 - coderd/updatecheck/updatecheck_test.go | 1 - coderd/updatecheck_test.go | 1 - coderd/userauth_test.go | 1 - coderd/userpassword/userpassword_test.go | 2 -- coderd/users_test.go | 3 --- coderd/util/maps/maps_test.go | 1 - coderd/util/strings/strings_test.go | 1 - coderd/util/xio/limitwriter_test.go | 1 - coderd/webpush/webpush.go | 1 - coderd/workspaceagents_test.go | 3 --- coderd/workspaceapps/apptest/apptest.go | 2 -- coderd/workspaceapps/appurl/appurl_test.go | 5 ----- coderd/workspaceapps/db_test.go | 1 - coderd/workspaceapps/request_test.go | 1 - coderd/workspaceapps/stats_test.go | 1 - coderd/workspaceapps/token_test.go | 1 - coderd/workspaceapps_test.go | 2 -- coderd/workspaces_test.go | 5 ----- coderd/workspacestats/activitybump_test.go | 2 -- codersdk/agentsdk/logs_test.go | 2 -- codersdk/client_internal_test.go | 2 -- codersdk/deployment_internal_test.go | 1 - codersdk/deployment_test.go | 4 ---- codersdk/healthsdk/healthsdk_test.go | 1 - codersdk/healthsdk/interfaces_internal_test.go | 1 - codersdk/name_test.go | 6 ------ codersdk/pagination_test.go | 1 - codersdk/richparameters_test.go | 1 - codersdk/time_test.go | 3 --- codersdk/workspacedisplaystatus_internal_test.go | 1 - cryptorand/strings_test.go | 1 - enterprise/audit/audit_test.go | 1 - enterprise/audit/diff_internal_test.go | 1 - enterprise/cli/start_test.go | 2 -- enterprise/coderd/authorize_test.go | 1 - enterprise/coderd/coderd_test.go | 2 -- enterprise/coderd/enidpsync/organizations_test.go | 1 - enterprise/coderd/httpmw/provisionerdaemon_test.go | 1 - enterprise/coderd/insights_test.go | 2 -- enterprise/coderd/license/license_test.go | 1 - enterprise/coderd/prebuilds/claim_test.go | 1 - enterprise/coderd/prebuilds/membership_test.go | 1 - .../coderd/prebuilds/metricscollector_test.go | 8 -------- enterprise/coderd/prebuilds/reconcile_test.go | 1 - enterprise/coderd/provisionerdaemons_test.go | 1 - enterprise/coderd/provisionerkeys_test.go | 1 - enterprise/coderd/proxyhealth/proxyhealth.go | 1 - enterprise/coderd/roles_test.go | 1 - enterprise/coderd/schedule/template_test.go | 2 -- enterprise/coderd/templates_test.go | 1 - enterprise/coderd/userauth_test.go | 1 - enterprise/coderd/users_test.go | 1 - enterprise/coderd/workspaceproxy_internal_test.go | 1 - enterprise/coderd/workspaces_test.go | 1 - enterprise/provisionerd/remoteprovisioners_test.go | 1 - enterprise/replicasync/replicasync.go | 1 - enterprise/wsproxy/wsproxy_test.go | 2 -- examples/examples_test.go | 1 - helm/coder/tests/chart_test.go | 4 ---- helm/provisioner/tests/chart_test.go | 4 ---- provisioner/terraform/diagnostic_test.go | 1 - provisioner/terraform/executor_internal_test.go | 1 - provisioner/terraform/parse_test.go | 1 - provisioner/terraform/provision_test.go | 2 -- provisioner/terraform/resources_test.go | 5 ----- provisioner/terraform/tfparse/tfparse_test.go | 1 - provisionersdk/provisionertags_test.go | 1 - pty/ptytest/ptytest_test.go | 1 - scaletest/agentconn/config_test.go | 1 - scaletest/createworkspaces/config_test.go | 2 -- scaletest/harness/strategies.go | 1 - scaletest/harness/strategies_test.go | 1 - scaletest/placebo/config_test.go | 1 - scaletest/reconnectingpty/config_test.go | 1 - scaletest/workspacebuild/config_test.go | 1 - scripts/apitypings/main_test.go | 1 - scripts/release/main_internal_test.go | 2 -- scripts/releasemigrations/main.go | 1 - scripts/typegen/main.go | 1 - site/site.go | 1 - site/site_test.go | 1 - tailnet/configmaps_internal_test.go | 1 - tailnet/convert_test.go | 1 - tailnet/telemetry_internal_test.go | 1 - vpn/tunnel_internal_test.go | 1 - vpn/version_test.go | 2 -- 214 files changed, 371 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index 569b66d19fe29..d417d93ef166d 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -547,7 +547,6 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26 // channel to synchronize the results and avoid both messy // mutex logic and overloading the API. for _, md := range manifest.Metadata { - // We send the result to the channel in the goroutine to avoid // sending the same result multiple times. So, we don't care about // the return values. diff --git a/agent/agent_test.go b/agent/agent_test.go index 244fa7a899211..2a9c88b108f94 100644 --- a/agent/agent_test.go +++ b/agent/agent_test.go @@ -130,7 +130,6 @@ func TestAgent_Stats_SSH(t *testing.T) { t.Parallel() for _, port := range sshPorts { - t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Parallel() @@ -342,7 +341,6 @@ func TestAgent_SessionExec(t *testing.T) { t.Parallel() for _, port := range sshPorts { - t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Parallel() @@ -468,7 +466,6 @@ func TestAgent_SessionTTYShell(t *testing.T) { } for _, port := range sshPorts { - t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) { t.Parallel() @@ -611,7 +608,6 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) { @@ -688,7 +684,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) { //nolint:paralleltest // These tests need to swap the banner func. for _, port := range sshPorts { - sshClient, err := conn.SSHClientOnPort(ctx, port) require.NoError(t, err) t.Cleanup(func() { @@ -696,7 +691,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) { }) for i, test := range tests { - t.Run(fmt.Sprintf("(:%d)/%d", port, i), func(t *testing.T) { // Set new banner func and wait for the agent to call it to update the // banner. @@ -1209,7 +1203,6 @@ func TestAgent_CoderEnvVars(t *testing.T) { t.Parallel() for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_AGENT_NAME"} { - t.Run(key, func(t *testing.T) { t.Parallel() @@ -1232,7 +1225,6 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) { // For some reason this test produces a TTY locally and a non-TTY in CI // so we don't test for the absence of SSH_TTY. for _, key := range []string{"SSH_CONNECTION", "SSH_CLIENT"} { - t.Run(key, func(t *testing.T) { t.Parallel() @@ -1275,7 +1267,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.key, func(t *testing.T) { t.Parallel() @@ -1795,7 +1786,6 @@ func TestAgent_ReconnectingPTY(t *testing.T) { t.Setenv("LANG", "C") for _, backendType := range backends { - t.Run(backendType, func(t *testing.T) { if backendType == "Screen" { if runtime.GOOS != "linux" { @@ -2495,7 +2485,6 @@ func TestAgent_Dial(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/agent/agentcontainers/containers_internal_test.go b/agent/agentcontainers/containers_internal_test.go index 85d5690eb5bf9..a60dec75cd845 100644 --- a/agent/agentcontainers/containers_internal_test.go +++ b/agent/agentcontainers/containers_internal_test.go @@ -41,7 +41,6 @@ func TestWrapDockerExec(t *testing.T) { }, } for _, tt := range tests { - // appease the linter even though this isn't needed anymore t.Run(tt.name, func(t *testing.T) { t.Parallel() actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...) @@ -54,7 +53,6 @@ func TestWrapDockerExec(t *testing.T) { func TestConvertDockerPort(t *testing.T) { t.Parallel() - //nolint:paralleltest // variable recapture no longer required for _, tc := range []struct { name string in string @@ -101,7 +99,6 @@ func TestConvertDockerPort(t *testing.T) { expectError: "invalid port", }, } { - //nolint: paralleltest // variable recapture no longer required t.Run(tc.name, func(t *testing.T) { t.Parallel() actualPort, actualNetwork, actualErr := convertDockerPort(tc.in) @@ -151,7 +148,6 @@ func TestConvertDockerVolume(t *testing.T) { expectError: "invalid volume", }, } { - t.Run(tc.name, func(t *testing.T) { t.Parallel() }) diff --git a/agent/agentscripts/agentscripts.go b/agent/agentscripts/agentscripts.go index 80c7b4e8c3517..1dfcde8adb009 100644 --- a/agent/agentscripts/agentscripts.go +++ b/agent/agentscripts/agentscripts.go @@ -177,7 +177,6 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S if script.Cron == "" { continue } - _, err := r.cron.AddFunc(script.Cron, func() { err := r.trackRun(r.cronCtx, script.WorkspaceAgentScript, ExecuteCronScripts) if err != nil { diff --git a/agent/agentssh/x11_internal_test.go b/agent/agentssh/x11_internal_test.go index a8e553e911128..f49242eb9f730 100644 --- a/agent/agentssh/x11_internal_test.go +++ b/agent/agentssh/x11_internal_test.go @@ -228,7 +228,6 @@ func Test_addXauthEntry(t *testing.T) { require.NoError(t, err) for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/agent/proto/compare_test.go b/agent/proto/compare_test.go index b545e9b1b76a3..1e2645c59d5bc 100644 --- a/agent/proto/compare_test.go +++ b/agent/proto/compare_test.go @@ -67,7 +67,6 @@ func TestLabelsEqual(t *testing.T) { eq: false, }, } { - t.Run(tc.name, func(t *testing.T) { t.Parallel() require.Equal(t, tc.eq, proto.LabelsEqual(tc.a, tc.b)) diff --git a/agent/proto/resourcesmonitor/queue_test.go b/agent/proto/resourcesmonitor/queue_test.go index a35a2dd48eff0..770cf9e732ac7 100644 --- a/agent/proto/resourcesmonitor/queue_test.go +++ b/agent/proto/resourcesmonitor/queue_test.go @@ -65,7 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() queue := resourcesmonitor.NewQueue(20) diff --git a/agent/proto/resourcesmonitor/resources_monitor_test.go b/agent/proto/resourcesmonitor/resources_monitor_test.go index 89b292e130e8f..da8ffef293903 100644 --- a/agent/proto/resourcesmonitor/resources_monitor_test.go +++ b/agent/proto/resourcesmonitor/resources_monitor_test.go @@ -195,7 +195,6 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/apiversion/apiversion_test.go b/apiversion/apiversion_test.go index 91e93f25619e8..dfe80bdb731a5 100644 --- a/apiversion/apiversion_test.go +++ b/apiversion/apiversion_test.go @@ -72,7 +72,6 @@ func TestAPIVersionValidate(t *testing.T) { expectedError: "no longer supported", }, } { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/buildinfo/buildinfo_test.go b/buildinfo/buildinfo_test.go index c50a93000171a..ac9f5cd4dee83 100644 --- a/buildinfo/buildinfo_test.go +++ b/buildinfo/buildinfo_test.go @@ -93,7 +93,6 @@ func TestBuildInfo(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2), diff --git a/cli/agent_internal_test.go b/cli/agent_internal_test.go index 42f05d30d3dc0..02d65baaf623c 100644 --- a/cli/agent_internal_test.go +++ b/cli/agent_internal_test.go @@ -54,7 +54,6 @@ func Test_extractPort(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() got, err := extractPort(tt.urlString) diff --git a/cli/autoupdate_test.go b/cli/autoupdate_test.go index b108e5d547999..84647b0553d1c 100644 --- a/cli/autoupdate_test.go +++ b/cli/autoupdate_test.go @@ -62,7 +62,6 @@ func TestAutoUpdate(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() client := coderdtest.New(t, nil) diff --git a/cli/clitest/golden.go b/cli/clitest/golden.go index 197ae6de4f474..fd44b523b9c9f 100644 --- a/cli/clitest/golden.go +++ b/cli/clitest/golden.go @@ -71,7 +71,6 @@ ExtractCommandPathsLoop: } for _, tt := range cases { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/cli/cliui/agent_test.go b/cli/cliui/agent_test.go index 6e1b34c023be9..7c3b71a204c3d 100644 --- a/cli/cliui/agent_test.go +++ b/cli/cliui/agent_test.go @@ -369,7 +369,6 @@ func TestAgent(t *testing.T) { wantErr: true, }, } { - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -648,7 +647,6 @@ func TestPeerDiagnostics(t *testing.T) { }, } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() r, w := io.Pipe() @@ -852,7 +850,6 @@ func TestConnDiagnostics(t *testing.T) { }, } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() r, w := io.Pipe() diff --git a/cli/cliui/provisionerjob_test.go b/cli/cliui/provisionerjob_test.go index afbd61c55c76b..77310e9536321 100644 --- a/cli/cliui/provisionerjob_test.go +++ b/cli/cliui/provisionerjob_test.go @@ -124,7 +124,6 @@ func TestProvisionerJob(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/cli/cliui/resources_internal_test.go b/cli/cliui/resources_internal_test.go index 7c69ed8f28c43..934322b5e9fb9 100644 --- a/cli/cliui/resources_internal_test.go +++ b/cli/cliui/resources_internal_test.go @@ -40,7 +40,6 @@ func TestRenderAgentVersion(t *testing.T) { }, } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion) diff --git a/cli/cliui/table_test.go b/cli/cliui/table_test.go index a66cb57221cf6..4e82707f3fec8 100644 --- a/cli/cliui/table_test.go +++ b/cli/cliui/table_test.go @@ -169,7 +169,6 @@ foo 10 [a, b, c] foo1 11 foo2 12 fo // Test with pointer values. inPtr := make([]*tableTest1, len(in)) for i, v := range in { - inPtr[i] = &v } out, err = cliui.DisplayTable(inPtr, "", nil) diff --git a/cli/cliutil/levenshtein/levenshtein_test.go b/cli/cliutil/levenshtein/levenshtein_test.go index cbad97844e677..a210dd9253434 100644 --- a/cli/cliutil/levenshtein/levenshtein_test.go +++ b/cli/cliutil/levenshtein/levenshtein_test.go @@ -95,7 +95,6 @@ func Test_Levenshtein_Matches(t *testing.T) { Expected: []string{"kubernetes"}, }, } { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() actual := levenshtein.Matches(tt.Needle, tt.MaxDistance, tt.Haystack...) @@ -179,7 +178,6 @@ func Test_Levenshtein_Distance(t *testing.T) { Error: levenshtein.ErrMaxDist.Error(), }, } { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() actual, err := levenshtein.Distance(tt.A, tt.B, tt.MaxDist) diff --git a/cli/cliutil/provisionerwarn_test.go b/cli/cliutil/provisionerwarn_test.go index 40b2e39f6986f..878f08f822330 100644 --- a/cli/cliutil/provisionerwarn_test.go +++ b/cli/cliutil/provisionerwarn_test.go @@ -59,7 +59,6 @@ func TestWarnMatchedProvisioners(t *testing.T) { }, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() var w strings.Builder diff --git a/cli/configssh_internal_test.go b/cli/configssh_internal_test.go index 345933ef20a92..0ddfedf077fbb 100644 --- a/cli/configssh_internal_test.go +++ b/cli/configssh_internal_test.go @@ -118,7 +118,6 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -157,7 +156,6 @@ func Test_sshConfigProxyCommandEscape(t *testing.T) { } // nolint:paralleltest // Fixes a flake for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { if runtime.GOOS == "windows" { t.Skip("Windows doesn't typically execute via /bin/sh or cmd.exe, so this test is not applicable.") @@ -207,7 +205,6 @@ func Test_sshConfigMatchExecEscape(t *testing.T) { } // nolint:paralleltest // Fixes a flake for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { cmd := "/bin/sh" arg := "-c" @@ -290,7 +287,6 @@ func Test_sshConfigExecEscapeSeparatorForce(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() found, err := sshConfigProxyCommandEscape(tt.path, tt.forceUnix) @@ -366,7 +362,6 @@ func Test_sshConfigOptions_addOption(t *testing.T) { } for _, tt := range testCases { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/configssh_test.go b/cli/configssh_test.go index bd49e5171fcae..1ffe93a7b838c 100644 --- a/cli/configssh_test.go +++ b/cli/configssh_test.go @@ -688,7 +688,6 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/exp_errors_test.go b/cli/exp_errors_test.go index 7e604c4a7e670..61e11dc770afc 100644 --- a/cli/exp_errors_test.go +++ b/cli/exp_errors_test.go @@ -49,7 +49,6 @@ ExtractCommandPathsLoop: } for _, tt := range cases { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/gitauth/askpass_test.go b/cli/gitauth/askpass_test.go index f482ceb5e296a..e9213daf37bda 100644 --- a/cli/gitauth/askpass_test.go +++ b/cli/gitauth/askpass_test.go @@ -60,7 +60,6 @@ func TestParse(t *testing.T) { wantHost: "http://wow.io", }, } { - t.Run(tc.in, func(t *testing.T) { t.Parallel() user, host, err := gitauth.ParseAskpass(tc.in) diff --git a/cli/notifications_test.go b/cli/notifications_test.go index 7cd2bea5e0f62..0e8ece285b450 100644 --- a/cli/notifications_test.go +++ b/cli/notifications_test.go @@ -48,7 +48,6 @@ func TestNotifications(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/open_internal_test.go b/cli/open_internal_test.go index d9886a7583f59..5c3ec338aca42 100644 --- a/cli/open_internal_test.go +++ b/cli/open_internal_test.go @@ -47,7 +47,6 @@ func Test_resolveAgentAbsPath(t *testing.T) { {"fail with no working directory and rel path on windows", args{relOrAbsPath: "my\\path", agentOS: "windows"}, "", true}, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -156,7 +155,6 @@ func Test_buildAppLinkURL(t *testing.T) { expectedLink: "https://coder.tld/path-base/@username/Test-Workspace.a-workspace-agent/apps/app-slug/", }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() baseURL, err := url.Parse(tt.baseURL) diff --git a/cli/open_test.go b/cli/open_test.go index dce6747fce6c8..698a4d777984b 100644 --- a/cli/open_test.go +++ b/cli/open_test.go @@ -113,7 +113,6 @@ func TestOpenVSCode(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -240,7 +239,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -414,7 +412,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -578,7 +575,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/organizationroles.go b/cli/organizationroles.go index 1c57fad4b2594..3651baea88d2f 100644 --- a/cli/organizationroles.go +++ b/cli/organizationroles.go @@ -435,7 +435,6 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str // Construct new site perms with only new perms for the resource keep := make([]codersdk.Permission, 0) for _, perm := range role.OrganizationPermissions { - if string(perm.ResourceType) != resource { keep = append(keep, perm) } diff --git a/cli/organizationsettings.go b/cli/organizationsettings.go index 9e5f373fb65ba..391a4f72e27fd 100644 --- a/cli/organizationsettings.go +++ b/cli/organizationsettings.go @@ -116,7 +116,6 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti } for _, set := range settings { - patch := set.Patch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, @@ -192,7 +191,6 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett } for _, set := range settings { - fetch := set.Fetch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, diff --git a/cli/portforward_internal_test.go b/cli/portforward_internal_test.go index ca44f8a70c956..5698363f95e5e 100644 --- a/cli/portforward_internal_test.go +++ b/cli/portforward_internal_test.go @@ -103,7 +103,6 @@ func Test_parsePortForwards(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/portforward_test.go b/cli/portforward_test.go index 337726fc4b001..e995b31950314 100644 --- a/cli/portforward_test.go +++ b/cli/portforward_test.go @@ -145,7 +145,6 @@ func TestPortForward(t *testing.T) { ) for _, c := range cases { - t.Run(c.name+"_OnePort", func(t *testing.T) { t.Parallel() p1 := setupTestListener(t, c.setupRemote(t)) diff --git a/cli/provisionerjobs_test.go b/cli/provisionerjobs_test.go index ddab340471b67..b33fd8b984dc7 100644 --- a/cli/provisionerjobs_test.go +++ b/cli/provisionerjobs_test.go @@ -152,7 +152,6 @@ func TestProvisionerJobs(t *testing.T) { {"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false}, {"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false}, } { - wantMsg := "OK" if !tt.wantCancelled { wantMsg = "FAIL" diff --git a/cli/root_internal_test.go b/cli/root_internal_test.go index 96f32f6e3fc26..9eb3fe7609582 100644 --- a/cli/root_internal_test.go +++ b/cli/root_internal_test.go @@ -76,7 +76,6 @@ func Test_formatExamples(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/schedule_internal_test.go b/cli/schedule_internal_test.go index 9fc24f4702e1f..dea98f97d09fb 100644 --- a/cli/schedule_internal_test.go +++ b/cli/schedule_internal_test.go @@ -100,7 +100,6 @@ func TestParseCLISchedule(t *testing.T) { expectedError: errInvalidTimeFormat.Error(), }, } { - //nolint:paralleltest // t.Setenv t.Run(testCase.name, func(t *testing.T) { t.Setenv("TZ", testCase.tzEnv) diff --git a/cli/schedule_test.go b/cli/schedule_test.go index 397ce02249655..02997a9a4c40d 100644 --- a/cli/schedule_test.go +++ b/cli/schedule_test.go @@ -341,7 +341,6 @@ func TestScheduleOverride(t *testing.T) { } for _, tt := range tests { - t.Run(tt.command, func(t *testing.T) { // Given // Set timezone to Asia/Kolkata to surface any timezone-related bugs. diff --git a/cli/server.go b/cli/server.go index ebc7e3328bc4f..a5f8277576bdf 100644 --- a/cli/server.go +++ b/cli/server.go @@ -1202,7 +1202,6 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. var wg sync.WaitGroup for i, provisionerDaemon := range provisionerDaemons { id := i + 1 - wg.Add(1) go func() { defer wg.Done() @@ -1680,7 +1679,6 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion, // Expensively check which certificate matches the client hello. for _, cert := range certs { - if err := hi.SupportsCertificate(&cert); err == nil { return &cert, nil } diff --git a/cli/server_internal_test.go b/cli/server_internal_test.go index 25f2d7f353d71..263445ccabd6f 100644 --- a/cli/server_internal_test.go +++ b/cli/server_internal_test.go @@ -62,7 +62,6 @@ func Test_configureCipherSuites(t *testing.T) { cipherByName := func(cipher string) *tls.CipherSuite { for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) { if cipher == c.Name { - return c } } @@ -173,7 +172,6 @@ func Test_configureCipherSuites(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := context.Background() @@ -245,7 +243,6 @@ func TestRedirectHTTPToHTTPSDeprecation(t *testing.T) { } for _, tc := range testcases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) @@ -310,7 +307,6 @@ func TestIsDERPPath(t *testing.T) { }, } for _, tc := range testcases { - t.Run(tc.path, func(t *testing.T) { t.Parallel() require.Equal(t, tc.expected, isDERPPath(tc.path)) @@ -363,7 +359,6 @@ func TestEscapePostgresURLUserInfo(t *testing.T) { }, } for _, tc := range testcases { - t.Run(tc.input, func(t *testing.T) { t.Parallel() o, err := escapePostgresURLUserInfo(tc.input) diff --git a/cli/server_test.go b/cli/server_test.go index 4346d44f1e1ff..2d0bbdd24e83b 100644 --- a/cli/server_test.go +++ b/cli/server_test.go @@ -471,7 +471,6 @@ func TestServer(t *testing.T) { expectGithubDefaultProviderConfigured: true, }, } { - t.Run(tc.name, func(t *testing.T) { runGitHubProviderTest(t, tc) }) @@ -629,7 +628,6 @@ func TestServer(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() ctx, cancelFunc := context.WithCancel(context.Background()) @@ -883,7 +881,6 @@ func TestServer(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/cli/ssh_test.go b/cli/ssh_test.go index a6dcfd62d826b..127d57b22ae75 100644 --- a/cli/ssh_test.go +++ b/cli/ssh_test.go @@ -1517,7 +1517,6 @@ func TestSSH(t *testing.T) { pty.ExpectMatchContext(ctx, "ping pong") for i, sock := range sockets { - // Start the listener on the "local machine". l, err := net.Listen("unix", sock.local) require.NoError(t, err) @@ -1641,7 +1640,6 @@ func TestSSH(t *testing.T) { } for _, tc := range tcs { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/cli/start_test.go b/cli/start_test.go index 6358f153c482f..f64a3f0646303 100644 --- a/cli/start_test.go +++ b/cli/start_test.go @@ -343,7 +343,6 @@ func TestStartAutoUpdate(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/cli/templateedit_test.go b/cli/templateedit_test.go index 03f8d77db8dfe..b551a4abcdb1d 100644 --- a/cli/templateedit_test.go +++ b/cli/templateedit_test.go @@ -299,7 +299,6 @@ func TestTemplateEdit(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -416,7 +415,6 @@ func TestTemplateEdit(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/cli/templatepull_test.go b/cli/templatepull_test.go index c3ae6446fd647..5d999de15ed02 100644 --- a/cli/templatepull_test.go +++ b/cli/templatepull_test.go @@ -262,7 +262,6 @@ func TestTemplatePull_ToDir(t *testing.T) { // nolint: paralleltest // These tests change the current working dir, and is therefore unsuitable for parallelisation. for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { dir := t.TempDir() diff --git a/cli/templatepush_test.go b/cli/templatepush_test.go index d9bc7a4772f32..f7a31d5e0c25f 100644 --- a/cli/templatepush_test.go +++ b/cli/templatepush_test.go @@ -485,7 +485,6 @@ func TestTemplatePush(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/cli/util_internal_test.go b/cli/util_internal_test.go index bc698e487d8e9..6c42033f7c0bf 100644 --- a/cli/util_internal_test.go +++ b/cli/util_internal_test.go @@ -30,7 +30,6 @@ func TestDurationDisplay(t *testing.T) { {"24h1m1s", "1d"}, {"25h", "1d1h"}, } { - t.Run(testCase.Duration, func(t *testing.T) { t.Parallel() d, err := time.ParseDuration(testCase.Duration) @@ -71,7 +70,6 @@ func TestExtendedParseDuration(t *testing.T) { {"200y200y200y200y200y", 0, false}, {"9223372036854775807s", 0, false}, } { - t.Run(testCase.Duration, func(t *testing.T) { t.Parallel() actual, err := extendedParseDuration(testCase.Duration) diff --git a/cli/version_test.go b/cli/version_test.go index a9e65b855fd8a..14214e995f752 100644 --- a/cli/version_test.go +++ b/cli/version_test.go @@ -50,7 +50,6 @@ Full build of Coder, supports the server subcommand. Expected: expectedText, }, } { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) diff --git a/cli/vpndaemon_windows_test.go b/cli/vpndaemon_windows_test.go index 019c9c7e4e86a..b03f74ee796e5 100644 --- a/cli/vpndaemon_windows_test.go +++ b/cli/vpndaemon_windows_test.go @@ -52,7 +52,6 @@ func TestVPNDaemonRun(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/coderd/agentapi/manifest_internal_test.go b/coderd/agentapi/manifest_internal_test.go index e0da7b1c23670..7853041349126 100644 --- a/coderd/agentapi/manifest_internal_test.go +++ b/coderd/agentapi/manifest_internal_test.go @@ -80,7 +80,6 @@ func Test_vscodeProxyURI(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/agentapi/resources_monitoring_test.go b/coderd/agentapi/resources_monitoring_test.go index d64a25d278be8..c491d3789355b 100644 --- a/coderd/agentapi/resources_monitoring_test.go +++ b/coderd/agentapi/resources_monitoring_test.go @@ -280,7 +280,6 @@ func TestMemoryResourceMonitor(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -712,7 +711,6 @@ func TestVolumeResourceMonitor(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/agentmetrics/labels_test.go b/coderd/agentmetrics/labels_test.go index a32c8f7bf52b7..07f1998fed420 100644 --- a/coderd/agentmetrics/labels_test.go +++ b/coderd/agentmetrics/labels_test.go @@ -43,7 +43,6 @@ func TestValidateAggregationLabels(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/apikey/apikey_test.go b/coderd/apikey/apikey_test.go index 8da27674dbf2b..198ef11511b3e 100644 --- a/coderd/apikey/apikey_test.go +++ b/coderd/apikey/apikey_test.go @@ -107,7 +107,6 @@ func TestGenerate(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/audit_test.go b/coderd/audit_test.go index ca4cd3b9bda96..e6fa985038155 100644 --- a/coderd/audit_test.go +++ b/coderd/audit_test.go @@ -454,7 +454,6 @@ func TestAuditLogsFilter(t *testing.T) { } for _, testCase := range testCases { - // Test filtering t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/authorize_test.go b/coderd/authorize_test.go index 4399fed7bf13c..b8084211de60c 100644 --- a/coderd/authorize_test.go +++ b/coderd/authorize_test.go @@ -125,7 +125,6 @@ func TestCheckPermissions(t *testing.T) { } for _, c := range testCases { - t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/autobuild/lifecycle_executor_internal_test.go b/coderd/autobuild/lifecycle_executor_internal_test.go index e8c472fed89d6..2d556d58a2d5e 100644 --- a/coderd/autobuild/lifecycle_executor_internal_test.go +++ b/coderd/autobuild/lifecycle_executor_internal_test.go @@ -153,7 +153,6 @@ func Test_isEligibleForAutostart(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/autobuild/lifecycle_executor_test.go b/coderd/autobuild/lifecycle_executor_test.go index 38f34aef37720..65af911122aba 100644 --- a/coderd/autobuild/lifecycle_executor_test.go +++ b/coderd/autobuild/lifecycle_executor_test.go @@ -177,7 +177,6 @@ func TestExecutorAutostartTemplateUpdated(t *testing.T) { }, } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() var ( diff --git a/coderd/autobuild/notify/notifier_test.go b/coderd/autobuild/notify/notifier_test.go index b105b43797c10..4561fd2a45336 100644 --- a/coderd/autobuild/notify/notifier_test.go +++ b/coderd/autobuild/notify/notifier_test.go @@ -83,7 +83,6 @@ func TestNotifier(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/azureidentity/azureidentity_test.go b/coderd/azureidentity/azureidentity_test.go index fcbcc0c4ba8cb..bd94f836beb3b 100644 --- a/coderd/azureidentity/azureidentity_test.go +++ b/coderd/azureidentity/azureidentity_test.go @@ -47,7 +47,6 @@ func TestValidate(t *testing.T) { vmID: "960a4b4a-dab2-44ef-9b73-7753043b4f16", date: mustTime(time.RFC3339, "2024-04-22T17:32:44Z"), }} { - t.Run(tc.name, func(t *testing.T) { t.Parallel() vm, err := azureidentity.Validate(context.Background(), tc.payload, azureidentity.Options{ diff --git a/coderd/coderd_internal_test.go b/coderd/coderd_internal_test.go index e4d7c18b6bad9..b03985e1e157d 100644 --- a/coderd/coderd_internal_test.go +++ b/coderd/coderd_internal_test.go @@ -32,7 +32,6 @@ func TestStripSlashesMW(t *testing.T) { }) for _, tt := range tests { - t.Run("chi/"+tt.name, func(t *testing.T) { t.Parallel() req := httptest.NewRequest("GET", tt.inputPath, nil) diff --git a/coderd/database/db2sdk/db2sdk_test.go b/coderd/database/db2sdk/db2sdk_test.go index dfe3032e46db5..8e879569e014a 100644 --- a/coderd/database/db2sdk/db2sdk_test.go +++ b/coderd/database/db2sdk/db2sdk_test.go @@ -119,7 +119,6 @@ func TestProvisionerJobStatus(t *testing.T) { org := dbgen.Organization(t, db, database.Organization{}) for i, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() // Populate standard fields diff --git a/coderd/database/dbauthz/customroles_test.go b/coderd/database/dbauthz/customroles_test.go index d27a29392aef8..5e19f43ab5376 100644 --- a/coderd/database/dbauthz/customroles_test.go +++ b/coderd/database/dbauthz/customroles_test.go @@ -46,7 +46,6 @@ func TestInsertCustomRoles(t *testing.T) { merge := func(u ...interface{}) rbac.Roles { all := make([]rbac.Role, 0) for _, v := range u { - switch t := v.(type) { case rbac.Role: all = append(all, t) @@ -201,7 +200,6 @@ func TestInsertCustomRoles(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() db := dbmem.New() diff --git a/coderd/database/dbauthz/groupsauth_test.go b/coderd/database/dbauthz/groupsauth_test.go index e8a52677e85f5..79f936e103e09 100644 --- a/coderd/database/dbauthz/groupsauth_test.go +++ b/coderd/database/dbauthz/groupsauth_test.go @@ -135,7 +135,6 @@ func TestGroupsAuth(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/dbauthz/setup_test.go b/coderd/database/dbauthz/setup_test.go index 746b1f28dd0bf..29ca421d6f11e 100644 --- a/coderd/database/dbauthz/setup_test.go +++ b/coderd/database/dbauthz/setup_test.go @@ -458,7 +458,6 @@ type AssertRBAC struct { func values(ins ...any) []reflect.Value { out := make([]reflect.Value, 0) for _, input := range ins { - out = append(out, reflect.ValueOf(input)) } return out diff --git a/coderd/database/dbmem/dbmem.go b/coderd/database/dbmem/dbmem.go index d0db6000a6a73..7bdebd1e2b242 100644 --- a/coderd/database/dbmem/dbmem.go +++ b/coderd/database/dbmem/dbmem.go @@ -1797,7 +1797,6 @@ func (q *FakeQuerier) CustomRoles(_ context.Context, arg database.CustomRolesPar found := make([]database.CustomRole, 0) for _, role := range q.data.customRoles { - if len(arg.LookupRoles) > 0 { if !slices.ContainsFunc(arg.LookupRoles, func(pair database.NameOrganizationPair) bool { if pair.Name != role.Name { @@ -2867,7 +2866,6 @@ func (q *FakeQuerier) GetAuthorizationUserRoles(_ context.Context, userID uuid.U roles := make([]string, 0) for _, u := range q.users { if u.ID == userID { - roles = append(roles, u.RBACRoles...) roles = append(roles, "member") user = &u @@ -8070,7 +8068,6 @@ func (q *FakeQuerier) GetWorkspaceByOwnerIDAndName(_ context.Context, arg databa var found *database.WorkspaceTable for _, workspace := range q.workspaces { - if workspace.OwnerID != arg.OwnerID { continue } @@ -8128,7 +8125,6 @@ func (q *FakeQuerier) GetWorkspaceByWorkspaceAppID(_ context.Context, workspaceA defer q.mutex.RUnlock() for _, workspaceApp := range q.workspaceApps { - if workspaceApp.ID == workspaceAppID { return q.getWorkspaceByAgentIDNoLock(context.Background(), workspaceApp.AgentID) } diff --git a/coderd/database/dbmem/dbmem_test.go b/coderd/database/dbmem/dbmem_test.go index af53f0f02fecc..c3df828b95c98 100644 --- a/coderd/database/dbmem/dbmem_test.go +++ b/coderd/database/dbmem/dbmem_test.go @@ -188,7 +188,6 @@ func TestProxyByHostname(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/migrations/migrate_test.go b/coderd/database/migrations/migrate_test.go index f99c523a2c702..f5d84e6532083 100644 --- a/coderd/database/migrations/migrate_test.go +++ b/coderd/database/migrations/migrate_test.go @@ -288,7 +288,6 @@ func TestMigrateUpWithFixtures(t *testing.T) { }) for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/database/pubsub/pubsub_memory.go b/coderd/database/pubsub/pubsub_memory.go index 1d4330ab1ff8f..59a5730ff9808 100644 --- a/coderd/database/pubsub/pubsub_memory.go +++ b/coderd/database/pubsub/pubsub_memory.go @@ -73,7 +73,6 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error { var wg sync.WaitGroup for _, listener := range listeners { wg.Add(1) - go func() { defer wg.Done() listener.send(context.Background(), message) diff --git a/coderd/database/querier_test.go b/coderd/database/querier_test.go index 159b96ea3891e..dcfc997b268eb 100644 --- a/coderd/database/querier_test.go +++ b/coderd/database/querier_test.go @@ -1157,7 +1157,6 @@ func TestProxyByHostname(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -1395,7 +1394,6 @@ func TestGetUsers_IncludeSystem(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1863,7 +1861,6 @@ func TestReadCustomRoles(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -2506,7 +2503,6 @@ func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) { } for _, tc := range testCases { - // Capture loop variable to avoid data races t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -2947,7 +2943,6 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tz := range timezones { - t.Run(tz, func(t *testing.T) { t.Parallel() @@ -2995,7 +2990,6 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -3163,7 +3157,6 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() db, _ := dbtestutil.NewDB(t) @@ -3296,7 +3289,6 @@ func TestGetUserStatusCounts(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/devtunnel/tunnel_test.go b/coderd/devtunnel/tunnel_test.go index 64a3da023bad2..50573c19e5f27 100644 --- a/coderd/devtunnel/tunnel_test.go +++ b/coderd/devtunnel/tunnel_test.go @@ -48,7 +48,6 @@ func TestTunnel(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/externalauth/externalauth.go b/coderd/externalauth/externalauth.go index de443967ed9f5..9b8b87748e784 100644 --- a/coderd/externalauth/externalauth.go +++ b/coderd/externalauth/externalauth.go @@ -505,7 +505,6 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut ids := map[string]struct{}{} configs := []*Config{} for _, entry := range entries { - // Applies defaults to the config entry. // This allows users to very simply state that they type is "GitHub", // apply their client secret and ID, and have the UI appear nicely. diff --git a/coderd/externalauth/externalauth_internal_test.go b/coderd/externalauth/externalauth_internal_test.go index e72fabd1e3f97..f50593c019b4f 100644 --- a/coderd/externalauth/externalauth_internal_test.go +++ b/coderd/externalauth/externalauth_internal_test.go @@ -102,7 +102,6 @@ func TestGitlabDefaults(t *testing.T) { }, } for _, c := range tests { - t.Run(c.name, func(t *testing.T) { t.Parallel() applyDefaultsToConfig(&c.input) @@ -177,7 +176,6 @@ func Test_bitbucketServerConfigDefaults(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() applyDefaultsToConfig(tt.config) diff --git a/coderd/externalauth/externalauth_test.go b/coderd/externalauth/externalauth_test.go index 1aff61c4179b9..81cf5aa1f21e2 100644 --- a/coderd/externalauth/externalauth_test.go +++ b/coderd/externalauth/externalauth_test.go @@ -463,7 +463,6 @@ func TestConvertYAML(t *testing.T) { }}, Error: "device auth url must be provided", }} { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() output, err := externalauth.ConvertConfig(instrument, tc.Input, &url.URL{}) diff --git a/coderd/healthcheck/health/model_test.go b/coderd/healthcheck/health/model_test.go index dd47cbf6003e6..2ff51652f3275 100644 --- a/coderd/healthcheck/health/model_test.go +++ b/coderd/healthcheck/health/model_test.go @@ -21,7 +21,6 @@ func Test_MessageURL(t *testing.T) { {"default", health.CodeAccessURLFetch, "", "https://coder.com/docs/admin/monitoring/health-check#eacs03"}, {"custom docs base", health.CodeAccessURLFetch, "https://example.com/docs", "https://example.com/docs/admin/monitoring/health-check#eacs03"}, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() uut := health.Message{Code: tt.code} diff --git a/coderd/healthcheck/healthcheck_test.go b/coderd/healthcheck/healthcheck_test.go index 96da80148aced..2b49b3215e251 100644 --- a/coderd/healthcheck/healthcheck_test.go +++ b/coderd/healthcheck/healthcheck_test.go @@ -508,7 +508,6 @@ func TestHealthcheck(t *testing.T) { }, severity: health.SeverityError, }} { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/provisioner_test.go b/coderd/healthcheck/provisioner_test.go index 723daee0203ee..e2f0c6119ed09 100644 --- a/coderd/healthcheck/provisioner_test.go +++ b/coderd/healthcheck/provisioner_test.go @@ -335,7 +335,6 @@ func TestProvisionerDaemonReport(t *testing.T) { expectedItems: []healthsdk.ProvisionerDaemonsReportItem{}, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/workspaceproxy_internal_test.go b/coderd/healthcheck/workspaceproxy_internal_test.go index 395103c3b6f9e..be367ee2061c9 100644 --- a/coderd/healthcheck/workspaceproxy_internal_test.go +++ b/coderd/healthcheck/workspaceproxy_internal_test.go @@ -47,7 +47,6 @@ func Test_WorkspaceProxyReport_appendErrors(t *testing.T) { errs: []string{assert.AnError.Error(), "another error"}, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -85,7 +84,6 @@ func Test_calculateSeverity(t *testing.T) { {2, 0, 0, health.SeverityError}, {2, 0, 1, health.SeverityError}, } { - name := fmt.Sprintf("%d total, %d healthy, %d warning -> %s", tt.total, tt.healthy, tt.warning, tt.expected) t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/coderd/healthcheck/workspaceproxy_test.go b/coderd/healthcheck/workspaceproxy_test.go index 84c10a86330ff..e8fc7a339c408 100644 --- a/coderd/healthcheck/workspaceproxy_test.go +++ b/coderd/healthcheck/workspaceproxy_test.go @@ -172,7 +172,6 @@ func TestWorkspaceProxies(t *testing.T) { expectedSeverity: health.SeverityError, }, } { - if tt.name != "Enabled/ProxyWarnings" { continue } diff --git a/coderd/httpapi/cookie_test.go b/coderd/httpapi/cookie_test.go index e771afab606b9..e653e3653ba14 100644 --- a/coderd/httpapi/cookie_test.go +++ b/coderd/httpapi/cookie_test.go @@ -26,7 +26,6 @@ func TestStripCoderCookies(t *testing.T) { "coder_session_token=ok; oauth_state=wow; oauth_redirect=/", "", }} { - t.Run(tc.Input, func(t *testing.T) { t.Parallel() require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input)) diff --git a/coderd/httpapi/json_test.go b/coderd/httpapi/json_test.go index cd6ef58e6b00f..8cfe8068e7b2e 100644 --- a/coderd/httpapi/json_test.go +++ b/coderd/httpapi/json_test.go @@ -46,7 +46,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - t.Run(c.expected, func(t *testing.T) { t.Parallel() @@ -108,7 +107,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - t.Run(c.value, func(t *testing.T) { t.Parallel() @@ -151,7 +149,6 @@ func TestDuration(t *testing.T) { } for _, c := range cases { - t.Run(c.value, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/authorize_test.go b/coderd/httpmw/authorize_test.go index 55f68660e8146..4991dbeb9c46e 100644 --- a/coderd/httpmw/authorize_test.go +++ b/coderd/httpmw/authorize_test.go @@ -107,7 +107,6 @@ func TestExtractUserRoles(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/cors_test.go b/coderd/httpmw/cors_test.go index 0eecc296f476a..4d48d535a23e4 100644 --- a/coderd/httpmw/cors_test.go +++ b/coderd/httpmw/cors_test.go @@ -91,7 +91,6 @@ func TestWorkspaceAppCors(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/csrf_test.go b/coderd/httpmw/csrf_test.go index 65a33a74adeb5..62e8150fb099f 100644 --- a/coderd/httpmw/csrf_test.go +++ b/coderd/httpmw/csrf_test.go @@ -57,7 +57,6 @@ func TestCSRFExemptList(t *testing.T) { csrfmw := mw(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})).(*nosurf.CSRFHandler) for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/hsts_test.go b/coderd/httpmw/hsts_test.go index 3d9b543c8772d..0e36f8993c1dd 100644 --- a/coderd/httpmw/hsts_test.go +++ b/coderd/httpmw/hsts_test.go @@ -77,7 +77,6 @@ func TestHSTS(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/loggermw/logger_internal_test.go b/coderd/httpmw/loggermw/logger_internal_test.go index de846ba0eedd4..f372c665fda14 100644 --- a/coderd/httpmw/loggermw/logger_internal_test.go +++ b/coderd/httpmw/loggermw/logger_internal_test.go @@ -247,7 +247,6 @@ func TestRequestLogger_RouteParamsLogging(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/patternmatcher/routepatterns_test.go b/coderd/httpmw/patternmatcher/routepatterns_test.go index 992eed72356eb..623c22afbab92 100644 --- a/coderd/httpmw/patternmatcher/routepatterns_test.go +++ b/coderd/httpmw/patternmatcher/routepatterns_test.go @@ -108,7 +108,6 @@ func Test_RoutePatterns(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/realip_test.go b/coderd/httpmw/realip_test.go index f53b9397357c0..18b870ae379c2 100644 --- a/coderd/httpmw/realip_test.go +++ b/coderd/httpmw/realip_test.go @@ -200,7 +200,6 @@ func TestExtractAddress(t *testing.T) { } for _, test := range tests { - t.Run(test.Name, func(t *testing.T) { t.Parallel() @@ -235,7 +234,6 @@ func TestTrustedOrigins(t *testing.T) { // ipv6: trust an IPv4 network for _, trusted := range []string{"none", "ipv4", "ipv6"} { for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - name := fmt.Sprintf("%s-%s-%s", trusted, proto, strings.ToLower(header)) t.Run(name, func(t *testing.T) { @@ -309,7 +307,6 @@ func TestCorruptedHeaders(t *testing.T) { t.Parallel() for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - name := strings.ToLower(header) t.Run(name, func(t *testing.T) { @@ -362,7 +359,6 @@ func TestAddressFamilies(t *testing.T) { for _, clientFamily := range []string{"ipv4", "ipv6"} { for _, proxyFamily := range []string{"ipv4", "ipv6"} { for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { - name := fmt.Sprintf("%s-%s-%s", strings.ToLower(header), clientFamily, proxyFamily) t.Run(name, func(t *testing.T) { @@ -462,7 +458,6 @@ func TestFilterUntrusted(t *testing.T) { } for _, test := range tests { - t.Run(test.Name, func(t *testing.T) { t.Parallel() @@ -608,7 +603,6 @@ func TestApplicationProxy(t *testing.T) { } for _, test := range tests { - t.Run(test.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/recover_test.go b/coderd/httpmw/recover_test.go index 1f22247155a81..d4d4227ff15ef 100644 --- a/coderd/httpmw/recover_test.go +++ b/coderd/httpmw/recover_test.go @@ -52,7 +52,6 @@ func TestRecover(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/httpmw/workspaceparam_test.go b/coderd/httpmw/workspaceparam_test.go index 4dfddc08513c2..85e11cf3975fd 100644 --- a/coderd/httpmw/workspaceparam_test.go +++ b/coderd/httpmw/workspaceparam_test.go @@ -316,7 +316,6 @@ func TestWorkspaceAgentByNameParam(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() db, r := setupWorkspaceWithAgents(t, setupConfig{ diff --git a/coderd/idpsync/group.go b/coderd/idpsync/group.go index 54b8430b78da8..0b21c5b9ac84c 100644 --- a/coderd/idpsync/group.go +++ b/coderd/idpsync/group.go @@ -99,7 +99,6 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat // membership via the groups the user is in. userOrgs := make(map[uuid.UUID][]database.GetGroupsRow) for _, g := range userGroups { - userOrgs[g.Group.OrganizationID] = append(userOrgs[g.Group.OrganizationID], g) } @@ -337,7 +336,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai groups := make([]ExpectedGroup, 0) for _, group := range parsedGroups { - // Legacy group mappings happen before the regex filter. mappedGroupName, ok := s.LegacyNameMapping[group] if ok { @@ -354,7 +352,6 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai mappedGroupIDs, ok := s.Mapping[group] if ok { for _, gid := range mappedGroupIDs { - groups = append(groups, ExpectedGroup{OrganizationID: orgID, GroupID: &gid}) } continue diff --git a/coderd/idpsync/group_test.go b/coderd/idpsync/group_test.go index d8a9802ecc3c6..478d6557de551 100644 --- a/coderd/idpsync/group_test.go +++ b/coderd/idpsync/group_test.go @@ -243,7 +243,6 @@ func TestGroupSyncTable(t *testing.T) { } for _, tc := range testCases { - // The final test, "AllTogether", cannot run in parallel. // These tests are nearly instant using the memory db, so // this is still fast without being in parallel. @@ -341,7 +340,6 @@ func TestGroupSyncTable(t *testing.T) { }) for _, tc := range testCases { - orgID := uuid.New() SetupOrganization(t, s, db, user, orgID, tc) asserts = append(asserts, func(t *testing.T) { @@ -522,7 +520,6 @@ func TestApplyGroupDifference(t *testing.T) { } for _, tc := range testCase { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -712,7 +709,6 @@ func TestExpectedGroupEqual(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/idpsync/idpsync_test.go b/coderd/idpsync/idpsync_test.go index 7a5b6d2e19d17..f3dc9c2f07986 100644 --- a/coderd/idpsync/idpsync_test.go +++ b/coderd/idpsync/idpsync_test.go @@ -159,7 +159,6 @@ func TestParseStringSliceClaim(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/idpsync/role_test.go b/coderd/idpsync/role_test.go index d195ab4422a6c..6df091097b966 100644 --- a/coderd/idpsync/role_test.go +++ b/coderd/idpsync/role_test.go @@ -186,7 +186,6 @@ func TestRoleSyncTable(t *testing.T) { } for _, tc := range testCases { - // The final test, "AllTogether", cannot run in parallel. // These tests are nearly instant using the memory db, so // this is still fast without being in parallel. @@ -248,7 +247,6 @@ func TestRoleSyncTable(t *testing.T) { var asserts []func(t *testing.T) for _, tc := range testCases { - orgID := uuid.New() SetupOrganization(t, s, db, user, orgID, tc) asserts = append(asserts, func(t *testing.T) { diff --git a/coderd/inboxnotifications_internal_test.go b/coderd/inboxnotifications_internal_test.go index 4d84a1cc16a21..c99d376bb77e9 100644 --- a/coderd/inboxnotifications_internal_test.go +++ b/coderd/inboxnotifications_internal_test.go @@ -29,7 +29,6 @@ func TestInboxNotifications_ensureNotificationIcon(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/inboxnotifications_test.go b/coderd/inboxnotifications_test.go index 22deb81ce4df6..c43149d8c8211 100644 --- a/coderd/inboxnotifications_test.go +++ b/coderd/inboxnotifications_test.go @@ -57,7 +57,6 @@ func TestInboxNotification_Watch(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -393,7 +392,6 @@ func TestInboxNotifications_List(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/insights_internal_test.go b/coderd/insights_internal_test.go index b0867c944d268..d3302e23cc85b 100644 --- a/coderd/insights_internal_test.go +++ b/coderd/insights_internal_test.go @@ -144,7 +144,6 @@ func Test_parseInsightsStartAndEndTime(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -253,7 +252,6 @@ func Test_parseInsightsInterval_week(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -322,7 +320,6 @@ func TestLastReportIntervalHasAtLeastSixDays(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/insights_test.go b/coderd/insights_test.go index 8f323c38785f2..ded030351a3b3 100644 --- a/coderd/insights_test.go +++ b/coderd/insights_test.go @@ -550,7 +550,6 @@ func TestTemplateInsights_Golden(t *testing.T) { // Prepare all the templates. for _, template := range templates { - var parameters []*proto.RichParameter for _, parameter := range template.parameters { var options []*proto.RichParameterOption @@ -581,9 +580,7 @@ func TestTemplateInsights_Golden(t *testing.T) { ) var resources []*proto.Resource for _, user := range users { - for _, workspace := range user.workspaces { - if workspace.template != template { continue } @@ -1244,7 +1241,6 @@ func TestTemplateInsights_Golden(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -1259,7 +1255,6 @@ func TestTemplateInsights_Golden(t *testing.T) { _, _ = <-events, <-events for _, req := range tt.requests { - t.Run(req.name, func(t *testing.T) { t.Parallel() @@ -1487,7 +1482,6 @@ func TestUserActivityInsights_Golden(t *testing.T) { // Prepare all the templates. for _, template := range templates { - // Prepare all workspace resources (agents and apps). var ( createWorkspaces []func(uuid.UUID) @@ -1495,9 +1489,7 @@ func TestUserActivityInsights_Golden(t *testing.T) { ) var resources []*proto.Resource for _, user := range users { - for _, workspace := range user.workspaces { - if workspace.template != template { continue } @@ -2027,7 +2019,6 @@ func TestUserActivityInsights_Golden(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -2042,7 +2033,6 @@ func TestUserActivityInsights_Golden(t *testing.T) { _, _ = <-events, <-events for _, req := range tt.requests { - t.Run(req.name, func(t *testing.T) { t.Parallel() @@ -2155,7 +2145,6 @@ func TestTemplateInsights_RBAC(t *testing.T) { } for _, tt := range tests { - t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) { t.Parallel() @@ -2274,7 +2263,6 @@ func TestGenericInsights_RBAC(t *testing.T) { } for endpointName, endpoint := range endpoints { - t.Run(fmt.Sprintf("With%sEndpoint", endpointName), func(t *testing.T) { t.Parallel() @@ -2284,7 +2272,6 @@ func TestGenericInsights_RBAC(t *testing.T) { } for _, tt := range tests { - t.Run("AsOwner", func(t *testing.T) { t.Parallel() diff --git a/coderd/jobreaper/detector_test.go b/coderd/jobreaper/detector_test.go index 676ad5ee929c4..4078f92c03a36 100644 --- a/coderd/jobreaper/detector_test.go +++ b/coderd/jobreaper/detector_test.go @@ -844,7 +844,6 @@ func TestDetectorPushesLogs(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/jwtutils/jwt_test.go b/coderd/jwtutils/jwt_test.go index 2920398cdd239..9a9ae8d3f44fb 100644 --- a/coderd/jwtutils/jwt_test.go +++ b/coderd/jwtutils/jwt_test.go @@ -149,11 +149,9 @@ func TestClaims(t *testing.T) { } for _, tt := range types { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/metricscache/metricscache_test.go b/coderd/metricscache/metricscache_test.go index 61aec9117f9ce..4582187a33651 100644 --- a/coderd/metricscache/metricscache_test.go +++ b/coderd/metricscache/metricscache_test.go @@ -202,7 +202,6 @@ func TestCache_BuildTime(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/dispatch/inbox_test.go b/coderd/notifications/dispatch/inbox_test.go index 4b4b2abb40920..744623ed2c99f 100644 --- a/coderd/notifications/dispatch/inbox_test.go +++ b/coderd/notifications/dispatch/inbox_test.go @@ -69,7 +69,6 @@ func TestInbox(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/notifications_test.go b/coderd/notifications/notifications_test.go index 17487e69681b6..ec9edee4c8514 100644 --- a/coderd/notifications/notifications_test.go +++ b/coderd/notifications/notifications_test.go @@ -1283,7 +1283,6 @@ func TestNotificationTemplates_Golden(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -2005,7 +2004,6 @@ func TestNotificationTargetMatrix(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/notifications/render/gotmpl_test.go b/coderd/notifications/render/gotmpl_test.go index 8ed102c58193e..c49cab7b991fd 100644 --- a/coderd/notifications/render/gotmpl_test.go +++ b/coderd/notifications/render/gotmpl_test.go @@ -68,8 +68,6 @@ func TestGoTemplate(t *testing.T) { } for _, tc := range tests { - // unnecessary as of go1.22 but the linter is outdated - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/oauth2_test.go b/coderd/oauth2_test.go index 4dc81361b4741..e081d3e1483db 100644 --- a/coderd/oauth2_test.go +++ b/coderd/oauth2_test.go @@ -151,7 +151,6 @@ func TestOAuth2ProviderApps(t *testing.T) { require.NoError(t, err) for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -661,7 +660,6 @@ func TestOAuth2ProviderTokenExchange(t *testing.T) { }, } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -804,7 +802,6 @@ func TestOAuth2ProviderTokenRefresh(t *testing.T) { }, } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) @@ -996,7 +993,6 @@ func TestOAuth2ProviderRevoke(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitLong) diff --git a/coderd/pagination_internal_test.go b/coderd/pagination_internal_test.go index b1b8d18c746a3..18d98c2fab319 100644 --- a/coderd/pagination_internal_test.go +++ b/coderd/pagination_internal_test.go @@ -110,7 +110,6 @@ func TestPagination(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() rw := httptest.NewRecorder() diff --git a/coderd/prebuilds/preset_snapshot_test.go b/coderd/prebuilds/preset_snapshot_test.go index d626021c034e2..c0ce524c87a8e 100644 --- a/coderd/prebuilds/preset_snapshot_test.go +++ b/coderd/prebuilds/preset_snapshot_test.go @@ -418,7 +418,6 @@ func TestInProgressActions(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -648,7 +647,6 @@ func TestExpiredPrebuilds(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/presets_test.go b/coderd/presets_test.go index 29516d4c9334f..1239cb655a63f 100644 --- a/coderd/presets_test.go +++ b/coderd/presets_test.go @@ -78,7 +78,6 @@ func TestTemplateVersionPresets(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/prometheusmetrics/aggregator_test.go b/coderd/prometheusmetrics/aggregator_test.go index 2e1128b13004a..6cbe5514b1c2e 100644 --- a/coderd/prometheusmetrics/aggregator_test.go +++ b/coderd/prometheusmetrics/aggregator_test.go @@ -587,7 +587,6 @@ func TestLabelsAggregation(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/prometheusmetrics/prometheusmetrics_internal_test.go b/coderd/prometheusmetrics/prometheusmetrics_internal_test.go index 5af912225e22c..3a6ecec5c12ec 100644 --- a/coderd/prometheusmetrics/prometheusmetrics_internal_test.go +++ b/coderd/prometheusmetrics/prometheusmetrics_internal_test.go @@ -29,7 +29,6 @@ func TestFilterAcceptableAgentLabels(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/prometheusmetrics/prometheusmetrics_test.go b/coderd/prometheusmetrics/prometheusmetrics_test.go index be2ffe129ea8f..1ce6b72347999 100644 --- a/coderd/prometheusmetrics/prometheusmetrics_test.go +++ b/coderd/prometheusmetrics/prometheusmetrics_test.go @@ -99,7 +99,6 @@ func TestActiveUsers(t *testing.T) { }, Count: 2, }} { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -161,7 +160,6 @@ func TestUsers(t *testing.T) { }, Count: map[database.UserStatus]int{database.UserStatusActive: 3}, }} { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) @@ -250,7 +248,6 @@ func TestWorkspaceLatestBuildTotals(t *testing.T) { codersdk.ProvisionerJobRunning: 1, }, }} { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -327,7 +324,6 @@ func TestWorkspaceLatestBuildStatuses(t *testing.T) { codersdk.ProvisionerJobRunning: 1, }, }} { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() registry := prometheus.NewRegistry() @@ -660,7 +656,6 @@ func TestExperimentsMetric(t *testing.T) { } for _, tc := range tests { - t.Run(tc.name, func(t *testing.T) { t.Parallel() reg := prometheus.NewRegistry() diff --git a/coderd/promoauth/oauth2_test.go b/coderd/promoauth/oauth2_test.go index 1ed0d7da6f1af..5aeec4f0fb949 100644 --- a/coderd/promoauth/oauth2_test.go +++ b/coderd/promoauth/oauth2_test.go @@ -155,7 +155,6 @@ func TestGithubRateLimits(t *testing.T) { } for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/provisionerdserver/acquirer_test.go b/coderd/provisionerdserver/acquirer_test.go index 627eddbe09985..817bae45bbd60 100644 --- a/coderd/provisionerdserver/acquirer_test.go +++ b/coderd/provisionerdserver/acquirer_test.go @@ -466,7 +466,6 @@ func TestAcquirer_MatchTags(t *testing.T) { }, } for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/coderd/provisionerdserver/provisionerdserver_test.go b/coderd/provisionerdserver/provisionerdserver_test.go index 3a3cae1e86d2c..dfa767b297f4c 100644 --- a/coderd/provisionerdserver/provisionerdserver_test.go +++ b/coderd/provisionerdserver/provisionerdserver_test.go @@ -150,7 +150,6 @@ func TestAcquireJob(t *testing.T) { }}, } for _, tc := range cases { - t.Run(tc.name+"_InitiatorNotFound", func(t *testing.T) { t.Parallel() srv, db, _, pd := setup(t, false, nil) @@ -176,7 +175,6 @@ func TestAcquireJob(t *testing.T) { sdkproto.PrebuiltWorkspaceBuildStage_CREATE, sdkproto.PrebuiltWorkspaceBuildStage_CLAIM, } { - t.Run(tc.name+"_WorkspaceBuildJob_Stage"+prebuiltWorkspaceBuildStage.String(), func(t *testing.T) { t.Parallel() // Set the max session token lifetime so we can assert we @@ -1709,7 +1707,6 @@ func TestCompleteJob(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -2133,7 +2130,6 @@ func TestCompleteJob(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -2577,7 +2573,6 @@ func TestInsertWorkspacePresetsAndParameters(t *testing.T) { } for _, c := range testCases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/provisionerjobs_internal_test.go b/coderd/provisionerjobs_internal_test.go index 6d9da70b747e6..bc94836028ce4 100644 --- a/coderd/provisionerjobs_internal_test.go +++ b/coderd/provisionerjobs_internal_test.go @@ -132,7 +132,6 @@ func TestConvertProvisionerJob_Unit(t *testing.T) { }, } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual := convertProvisionerJob(database.GetProvisionerJobsByIDsWithQueuePositionRow{ diff --git a/coderd/rbac/authz.go b/coderd/rbac/authz.go index 5afd76f02a433..f57ed2585c068 100644 --- a/coderd/rbac/authz.go +++ b/coderd/rbac/authz.go @@ -760,7 +760,6 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string, uniqueRoleNames := actor.SafeRoleNames() roleStrings := make([]string, 0, len(uniqueRoleNames)) for _, roleName := range uniqueRoleNames { - roleStrings = append(roleStrings, roleName.String()) } return trace.WithAttributes( diff --git a/coderd/rbac/authz_internal_test.go b/coderd/rbac/authz_internal_test.go index e1785f7e3a15e..838c7bce1c5e8 100644 --- a/coderd/rbac/authz_internal_test.go +++ b/coderd/rbac/authz_internal_test.go @@ -243,7 +243,6 @@ func TestFilter(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() actor := tc.Actor @@ -1135,7 +1134,6 @@ func testAuthorize(t *testing.T, name string, subject Subject, sets ...[]authTes authorizer := NewAuthorizer(prometheus.NewRegistry()) for _, cases := range sets { for i, c := range cases { - caseName := fmt.Sprintf("%s/%d", name, i) t.Run(caseName, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/object_test.go b/coderd/rbac/object_test.go index b64534c7950bb..ff579b48c03af 100644 --- a/coderd/rbac/object_test.go +++ b/coderd/rbac/object_test.go @@ -165,7 +165,6 @@ func TestObjectEqual(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/regosql/compile_test.go b/coderd/rbac/regosql/compile_test.go index 0137e7a10a911..db83156058fe9 100644 --- a/coderd/rbac/regosql/compile_test.go +++ b/coderd/rbac/regosql/compile_test.go @@ -265,7 +265,6 @@ neq(input.object.owner, ""); } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() part := partialQueries(tc.Queries...) diff --git a/coderd/rbac/regosql/sqltypes/equality_test.go b/coderd/rbac/regosql/sqltypes/equality_test.go index cafe1870f283e..37922064466de 100644 --- a/coderd/rbac/regosql/sqltypes/equality_test.go +++ b/coderd/rbac/regosql/sqltypes/equality_test.go @@ -114,7 +114,6 @@ func TestEquality(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/regosql/sqltypes/member_test.go b/coderd/rbac/regosql/sqltypes/member_test.go index aece83bd0ccf9..e933989d7b0df 100644 --- a/coderd/rbac/regosql/sqltypes/member_test.go +++ b/coderd/rbac/regosql/sqltypes/member_test.go @@ -92,7 +92,6 @@ func TestMembership(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/roles.go b/coderd/rbac/roles.go index 49c7b01d58518..db26d62cec7e9 100644 --- a/coderd/rbac/roles.go +++ b/coderd/rbac/roles.go @@ -837,7 +837,6 @@ func Permissions(perms map[string][]policy.Action) []Permission { list := make([]Permission, 0, len(perms)) for k, actions := range perms { for _, act := range actions { - list = append(list, Permission{ Negate: false, ResourceType: k, diff --git a/coderd/rbac/roles_internal_test.go b/coderd/rbac/roles_internal_test.go index 694b3400939b2..f851280a0417e 100644 --- a/coderd/rbac/roles_internal_test.go +++ b/coderd/rbac/roles_internal_test.go @@ -229,7 +229,6 @@ func TestRoleByName(t *testing.T) { } for _, c := range testCases { - t.Run(c.Role.Identifier.String(), func(t *testing.T) { role, err := RoleByName(c.Role.Identifier) require.NoError(t, err, "role exists") diff --git a/coderd/rbac/roles_test.go b/coderd/rbac/roles_test.go index bb3d95c950ce4..eb1061ebdf193 100644 --- a/coderd/rbac/roles_test.go +++ b/coderd/rbac/roles_test.go @@ -35,7 +35,6 @@ func (a authSubject) Subjects() []authSubject { return []authSubject{a} } func TestBuiltInRoles(t *testing.T) { t.Parallel() for _, r := range rbac.SiteBuiltInRoles() { - t.Run(r.Identifier.String(), func(t *testing.T) { t.Parallel() require.NoError(t, r.Valid(), "invalid role") @@ -43,7 +42,6 @@ func TestBuiltInRoles(t *testing.T) { } for _, r := range rbac.OrganizationRoles(uuid.New()) { - t.Run(r.Identifier.String(), func(t *testing.T) { t.Parallel() require.NoError(t, r.Valid(), "invalid role") @@ -885,7 +883,6 @@ func TestRolePermissions(t *testing.T) { passed := true // nolint:tparallel,paralleltest for _, c := range testCases { - // nolint:tparallel,paralleltest // These share the same remainingPermissions map t.Run(c.Name, func(t *testing.T) { remainingSubjs := make(map[string]struct{}) @@ -984,7 +981,6 @@ func TestIsOrgRole(t *testing.T) { // nolint:paralleltest for _, c := range testCases { - t.Run(c.Identifier.String(), func(t *testing.T) { t.Parallel() ok := c.Identifier.IsOrgRole() @@ -1081,7 +1077,6 @@ func TestChangeSet(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/rbac/subject_test.go b/coderd/rbac/subject_test.go index e23c9865a6362..c1462b073ec35 100644 --- a/coderd/rbac/subject_test.go +++ b/coderd/rbac/subject_test.go @@ -119,7 +119,6 @@ func TestSubjectEqual(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/render/markdown_test.go b/coderd/render/markdown_test.go index 9a60ba1714044..4095cac3f07e7 100644 --- a/coderd/render/markdown_test.go +++ b/coderd/render/markdown_test.go @@ -79,7 +79,6 @@ func TestHTML(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/schedule/autostop_test.go b/coderd/schedule/autostop_test.go index a0d66371a35e8..85cc7b533a6ea 100644 --- a/coderd/schedule/autostop_test.go +++ b/coderd/schedule/autostop_test.go @@ -486,7 +486,6 @@ func TestCalculateAutoStop(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -621,7 +620,6 @@ func TestFindWeek(t *testing.T) { } for _, tz := range timezones { - t.Run("Loc/"+tz, func(t *testing.T) { t.Parallel() diff --git a/coderd/schedule/cron/cron_test.go b/coderd/schedule/cron/cron_test.go index 3db1b982faf1e..f48f75084a557 100644 --- a/coderd/schedule/cron/cron_test.go +++ b/coderd/schedule/cron/cron_test.go @@ -141,7 +141,6 @@ func Test_Weekly(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() actual, err := cron.Weekly(testCase.spec) diff --git a/coderd/searchquery/search_test.go b/coderd/searchquery/search_test.go index 8acdc41935fa6..5d14f6e31c55e 100644 --- a/coderd/searchquery/search_test.go +++ b/coderd/searchquery/search_test.go @@ -267,7 +267,6 @@ func TestSearchWorkspace(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() // TODO: Replace this with the mock database. @@ -352,7 +351,6 @@ func TestSearchAudit(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() // Do not use a real database, this is only used for an @@ -520,7 +518,6 @@ func TestSearchUsers(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() values, errs := searchquery.Users(c.Query) @@ -562,7 +559,6 @@ func TestSearchTemplates(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() // Do not use a real database, this is only used for an diff --git a/coderd/tailnet_test.go b/coderd/tailnet_test.go index 495d4b97cb91f..55b212237479f 100644 --- a/coderd/tailnet_test.go +++ b/coderd/tailnet_test.go @@ -257,7 +257,6 @@ func TestServerTailnet_ReverseProxy(t *testing.T) { port := ":4444" for i, ag := range agents { - ln, err := ag.TailnetConn().Listen("tcp", port) require.NoError(t, err) wln := &wrappedListener{Listener: ln} diff --git a/coderd/telemetry/telemetry_test.go b/coderd/telemetry/telemetry_test.go index 0ea89acd5d6c3..9338e87d6d31c 100644 --- a/coderd/telemetry/telemetry_test.go +++ b/coderd/telemetry/telemetry_test.go @@ -544,7 +544,6 @@ func TestRecordTelemetryStatus(t *testing.T) { {name: "Telemetry was disabled still disabled", recordedTelemetryEnabled: "false", telemetryEnabled: false, shouldReport: false}, {name: "Telemetry was disabled still disabled, invalid value", recordedTelemetryEnabled: "invalid", telemetryEnabled: false, shouldReport: false}, } { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/templateversions_test.go b/coderd/templateversions_test.go index a9a860747a2ac..1ad06bae38aee 100644 --- a/coderd/templateversions_test.go +++ b/coderd/templateversions_test.go @@ -604,7 +604,6 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) { }, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) @@ -1393,7 +1392,6 @@ func TestPaginatedTemplateVersions(t *testing.T) { file, err := client.Upload(egCtx, codersdk.ContentTypeTar, bytes.NewReader(data)) require.NoError(t, err) for i := 0; i < total; i++ { - eg.Go(func() error { templateVersion, err := client.CreateTemplateVersion(egCtx, user.OrganizationID, codersdk.CreateTemplateVersionRequest{ Name: uuid.NewString(), @@ -1466,7 +1464,6 @@ func TestPaginatedTemplateVersions(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/tracing/httpmw_test.go b/coderd/tracing/httpmw_test.go index ecd168fa1b842..ba1e2b879c345 100644 --- a/coderd/tracing/httpmw_test.go +++ b/coderd/tracing/httpmw_test.go @@ -77,7 +77,6 @@ func Test_Middleware(t *testing.T) { } for _, c := range cases { - name := strings.ReplaceAll(strings.TrimPrefix(c.path, "/"), "/", "_") t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/coderd/updatecheck/updatecheck_test.go b/coderd/updatecheck/updatecheck_test.go index a40888a25f66e..725ceb44d9d6f 100644 --- a/coderd/updatecheck/updatecheck_test.go +++ b/coderd/updatecheck/updatecheck_test.go @@ -112,7 +112,6 @@ func TestChecker_Latest(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/updatecheck_test.go b/coderd/updatecheck_test.go index 13e47ffc224ad..a81dcd63a2091 100644 --- a/coderd/updatecheck_test.go +++ b/coderd/updatecheck_test.go @@ -51,7 +51,6 @@ func TestUpdateCheck_NewVersion(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/userauth_test.go b/coderd/userauth_test.go index b84aaa7fb8c76..4c9412fda3fb7 100644 --- a/coderd/userauth_test.go +++ b/coderd/userauth_test.go @@ -1473,7 +1473,6 @@ func TestUserOIDC(t *testing.T) { }, }, } { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() opts := []oidctest.FakeIDPOpt{ diff --git a/coderd/userpassword/userpassword_test.go b/coderd/userpassword/userpassword_test.go index e3ad7e7e0700c..83a3bb532e606 100644 --- a/coderd/userpassword/userpassword_test.go +++ b/coderd/userpassword/userpassword_test.go @@ -27,7 +27,6 @@ func TestUserPasswordValidate(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() err := userpassword.Validate(tt.password) @@ -93,7 +92,6 @@ func TestUserPasswordCompare(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() if tt.shouldHash { diff --git a/coderd/users_test.go b/coderd/users_test.go index aef77ac33eaf9..bd0f138b6a339 100644 --- a/coderd/users_test.go +++ b/coderd/users_test.go @@ -1777,7 +1777,6 @@ func TestUsersFilter(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -2461,7 +2460,6 @@ func TestPaginatedUsers(t *testing.T) { eg, _ := errgroup.WithContext(ctx) // Create users for i := 0; i < total; i++ { - eg.Go(func() error { email := fmt.Sprintf("%d@coder.com", i) username := fmt.Sprintf("user%d", i) @@ -2519,7 +2517,6 @@ func TestPaginatedUsers(t *testing.T) { {name: "username search", limit: 3, allUsers: specialUsers, opt: usernameSearch}, } for _, tt := range tests { - t.Run(fmt.Sprintf("%s %d", tt.name, tt.limit), func(t *testing.T) { t.Parallel() diff --git a/coderd/util/maps/maps_test.go b/coderd/util/maps/maps_test.go index 655adc9c23a68..f8ad8ddbc4b36 100644 --- a/coderd/util/maps/maps_test.go +++ b/coderd/util/maps/maps_test.go @@ -70,7 +70,6 @@ func TestSubset(t *testing.T) { expected: true, }, } { - t.Run("#"+strconv.Itoa(idx), func(t *testing.T) { t.Parallel() diff --git a/coderd/util/strings/strings_test.go b/coderd/util/strings/strings_test.go index 6192ad7cfd4cf..5172fb08e1e69 100644 --- a/coderd/util/strings/strings_test.go +++ b/coderd/util/strings/strings_test.go @@ -30,7 +30,6 @@ func TestTruncate(t *testing.T) { {"foo", 0, ""}, {"foo", -1, ""}, } { - t.Run(tt.expected, func(t *testing.T) { t.Parallel() actual := strings.Truncate(tt.s, tt.n) diff --git a/coderd/util/xio/limitwriter_test.go b/coderd/util/xio/limitwriter_test.go index d9b1694268525..552b38f71f487 100644 --- a/coderd/util/xio/limitwriter_test.go +++ b/coderd/util/xio/limitwriter_test.go @@ -107,7 +107,6 @@ func TestLimitWriter(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/coderd/webpush/webpush.go b/coderd/webpush/webpush.go index 1587ac2875a2b..0f54a269cad00 100644 --- a/coderd/webpush/webpush.go +++ b/coderd/webpush/webpush.go @@ -103,7 +103,6 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk var mu sync.Mutex var eg errgroup.Group for _, subscription := range subscriptions { - eg.Go(func() error { // TODO: Implement some retry logic here. For now, this is just a // best-effort attempt. diff --git a/coderd/workspaceagents_test.go b/coderd/workspaceagents_test.go index 18e7776400d33..b3fb53c228ef8 100644 --- a/coderd/workspaceagents_test.go +++ b/coderd/workspaceagents_test.go @@ -1065,7 +1065,6 @@ func TestWorkspaceAgentListeningPorts(t *testing.T) { }, }, } { - t.Run("OK_"+tc.name, func(t *testing.T) { t.Parallel() @@ -1340,7 +1339,6 @@ func TestWorkspaceAgentContainers(t *testing.T) { }, }, } { - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -1692,7 +1690,6 @@ func TestWorkspaceAgent_LifecycleState(t *testing.T) { } //nolint:paralleltest // No race between setting the state and getting the workspace. for _, tt := range tests { - t.Run(string(tt.state), func(t *testing.T) { state, err := agentsdk.ProtoFromLifecycleState(tt.state) if tt.wantErr { diff --git a/coderd/workspaceapps/apptest/apptest.go b/coderd/workspaceapps/apptest/apptest.go index c2d2e291a913b..050e5d2fb9a6e 100644 --- a/coderd/workspaceapps/apptest/apptest.go +++ b/coderd/workspaceapps/apptest/apptest.go @@ -500,7 +500,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) { } for _, c := range cases { - if c.name == "Path" && appHostIsPrimary { // Workspace application auth does not apply to path apps // served from the primary access URL as no smuggling needs @@ -1685,7 +1684,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/appurl/appurl_test.go b/coderd/workspaceapps/appurl/appurl_test.go index a83b4ef63d3b9..9dfdb4452cdb9 100644 --- a/coderd/workspaceapps/appurl/appurl_test.go +++ b/coderd/workspaceapps/appurl/appurl_test.go @@ -56,7 +56,6 @@ func TestApplicationURLString(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -158,7 +157,6 @@ func TestParseSubdomainAppURL(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -378,7 +376,6 @@ func TestCompileHostnamePattern(t *testing.T) { } for _, c := range testCases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -390,7 +387,6 @@ func TestCompileHostnamePattern(t *testing.T) { require.Equal(t, expected, regex.String(), "generated regex does not match") for i, m := range c.matchCases { - t.Run(fmt.Sprintf("MatchCase%d", i), func(t *testing.T) { t.Parallel() @@ -459,7 +455,6 @@ func TestConvertAppURLForCSP(t *testing.T) { } for _, c := range testCases { - t.Run(c.name, func(t *testing.T) { t.Parallel() require.Equal(t, c.expected, appurl.ConvertAppHostForCSP(c.host, c.wildcard)) diff --git a/coderd/workspaceapps/db_test.go b/coderd/workspaceapps/db_test.go index 0779303308c1f..a1f3fb452fbe5 100644 --- a/coderd/workspaceapps/db_test.go +++ b/coderd/workspaceapps/db_test.go @@ -270,7 +270,6 @@ func Test_ResolveRequest(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/request_test.go b/coderd/workspaceapps/request_test.go index a09c1af1f270c..f1b0df6ae064a 100644 --- a/coderd/workspaceapps/request_test.go +++ b/coderd/workspaceapps/request_test.go @@ -272,7 +272,6 @@ func Test_RequestValidate(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() req := c.req diff --git a/coderd/workspaceapps/stats_test.go b/coderd/workspaceapps/stats_test.go index e007d80634de6..c98be2eb79142 100644 --- a/coderd/workspaceapps/stats_test.go +++ b/coderd/workspaceapps/stats_test.go @@ -280,7 +280,6 @@ func TestStatsCollector(t *testing.T) { // Run tests. for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps/token_test.go b/coderd/workspaceapps/token_test.go index 5c2f01116286c..94ee128bd9079 100644 --- a/coderd/workspaceapps/token_test.go +++ b/coderd/workspaceapps/token_test.go @@ -273,7 +273,6 @@ func Test_TokenMatchesRequest(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaceapps_test.go b/coderd/workspaceapps_test.go index 0b8c6b02e102f..8db2858e01e32 100644 --- a/coderd/workspaceapps_test.go +++ b/coderd/workspaceapps_test.go @@ -57,7 +57,6 @@ func TestGetAppHost(t *testing.T) { }, } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -182,7 +181,6 @@ func TestWorkspaceApplicationAuth(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspaces_test.go b/coderd/workspaces_test.go index 09030c07b012c..1a7f1f93f3b1e 100644 --- a/coderd/workspaces_test.go +++ b/coderd/workspaces_test.go @@ -652,7 +652,6 @@ func TestWorkspace(t *testing.T) { } for _, tc := range testCases { - // Capture range variable t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -1802,7 +1801,6 @@ func TestWorkspaceFilter(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() workspaces, err := client.Workspaces(ctx, c.Filter) @@ -2583,7 +2581,6 @@ func TestWorkspaceUpdateAutostart(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() var ( @@ -2763,7 +2760,6 @@ func TestWorkspaceUpdateTTL(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() @@ -2864,7 +2860,6 @@ func TestWorkspaceUpdateTTL(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.name, func(t *testing.T) { t.Parallel() diff --git a/coderd/workspacestats/activitybump_test.go b/coderd/workspacestats/activitybump_test.go index 8bb33000e27c6..d778e2fbd0f8a 100644 --- a/coderd/workspacestats/activitybump_test.go +++ b/coderd/workspacestats/activitybump_test.go @@ -158,9 +158,7 @@ func Test_ActivityBumpWorkspace(t *testing.T) { expectedBump: 0, }, } { - for _, tz := range timezones { - t.Run(tt.name+"/"+tz, func(t *testing.T) { t.Parallel() nextAutostart := tt.nextAutostart diff --git a/codersdk/agentsdk/logs_test.go b/codersdk/agentsdk/logs_test.go index 422d51b89aa71..05e4bc574efde 100644 --- a/codersdk/agentsdk/logs_test.go +++ b/codersdk/agentsdk/logs_test.go @@ -168,7 +168,6 @@ func TestStartupLogsWriter_Write(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -253,7 +252,6 @@ func TestStartupLogsSender(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/client_internal_test.go b/codersdk/client_internal_test.go index 7161d722c2cb5..cfd8bdbf26086 100644 --- a/codersdk/client_internal_test.go +++ b/codersdk/client_internal_test.go @@ -76,7 +76,6 @@ func TestIsConnectionErr(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -297,7 +296,6 @@ func Test_readBodyAsError(t *testing.T) { } for _, c := range tests { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/deployment_internal_test.go b/codersdk/deployment_internal_test.go index 4ddf63f6b961d..d350447fd638a 100644 --- a/codersdk/deployment_internal_test.go +++ b/codersdk/deployment_internal_test.go @@ -28,7 +28,6 @@ func TestRemoveTrailingVersionInfo(t *testing.T) { } for _, tc := range testCases { - stripped := removeTrailingVersionInfo(tc.Version) require.Equal(t, tc.ExpectedAfterStrippingInfo, stripped) } diff --git a/codersdk/deployment_test.go b/codersdk/deployment_test.go index 603e1a7143387..c18e5775f7ae9 100644 --- a/codersdk/deployment_test.go +++ b/codersdk/deployment_test.go @@ -196,7 +196,6 @@ func TestSSHConfig_ParseOptions(t *testing.T) { } for _, tt := range testCases { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() c := codersdk.SSHConfig{ @@ -277,7 +276,6 @@ func TestTimezoneOffsets(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() @@ -524,7 +522,6 @@ func TestFeatureComparison(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() @@ -618,7 +615,6 @@ func TestNotificationsCanBeDisabled(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/healthsdk/healthsdk_test.go b/codersdk/healthsdk/healthsdk_test.go index 8872b0f88d344..4a062da03f24d 100644 --- a/codersdk/healthsdk/healthsdk_test.go +++ b/codersdk/healthsdk/healthsdk_test.go @@ -148,7 +148,6 @@ func TestSummarize(t *testing.T) { }, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() actual := tt.br.Summarize(tt.pfx, tt.docsURL) diff --git a/codersdk/healthsdk/interfaces_internal_test.go b/codersdk/healthsdk/interfaces_internal_test.go index 3b591360dde3e..e5c3978383b35 100644 --- a/codersdk/healthsdk/interfaces_internal_test.go +++ b/codersdk/healthsdk/interfaces_internal_test.go @@ -160,7 +160,6 @@ func Test_generateInterfacesReport(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() r := generateInterfacesReport(&tc.state) diff --git a/codersdk/name_test.go b/codersdk/name_test.go index 26145bf460938..b4903846c4c23 100644 --- a/codersdk/name_test.go +++ b/codersdk/name_test.go @@ -60,7 +60,6 @@ func TestUsernameValid(t *testing.T) { {"123456789012345678901234567890123123456789012345678901234567890123", false}, } for _, testCase := range testCases { - t.Run(testCase.Username, func(t *testing.T) { t.Parallel() valid := codersdk.NameValid(testCase.Username) @@ -115,7 +114,6 @@ func TestTemplateDisplayNameValid(t *testing.T) { {"12345678901234567890123456789012345678901234567890123456789012345", false}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() valid := codersdk.DisplayNameValid(testCase.Name) @@ -156,7 +154,6 @@ func TestTemplateVersionNameValid(t *testing.T) { {"!!!!1 ?????", false}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() valid := codersdk.TemplateVersionNameValid(testCase.Name) @@ -197,7 +194,6 @@ func TestFrom(t *testing.T) { {"", ""}, } for _, testCase := range testCases { - t.Run(testCase.From, func(t *testing.T) { t.Parallel() converted := codersdk.UsernameFrom(testCase.From) @@ -243,7 +239,6 @@ func TestUserRealNameValid(t *testing.T) { {strings.Repeat("a", 129), false}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() err := codersdk.UserRealNameValid(testCase.Name) @@ -277,7 +272,6 @@ func TestGroupNameValid(t *testing.T) { {random256String, false}, } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() err := codersdk.GroupNameValid(testCase.Name) diff --git a/codersdk/pagination_test.go b/codersdk/pagination_test.go index 1dbc2400e4f8d..e5bb8002743f9 100644 --- a/codersdk/pagination_test.go +++ b/codersdk/pagination_test.go @@ -42,7 +42,6 @@ func TestPagination_asRequestOption(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/richparameters_test.go b/codersdk/richparameters_test.go index fac86e54404e7..66f23416115bd 100644 --- a/codersdk/richparameters_test.go +++ b/codersdk/richparameters_test.go @@ -322,7 +322,6 @@ func TestRichParameterValidation(t *testing.T) { } for _, tc := range tests { - t.Run(tc.parameterName+"-"+tc.value, func(t *testing.T) { t.Parallel() diff --git a/codersdk/time_test.go b/codersdk/time_test.go index 0741a006e6653..fd5314538d3d9 100644 --- a/codersdk/time_test.go +++ b/codersdk/time_test.go @@ -47,7 +47,6 @@ func TestNullTime_MarshalJSON(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -104,7 +103,6 @@ func TestNullTime_UnmarshalJSON(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() @@ -145,7 +143,6 @@ func TestNullTime_IsZero(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/codersdk/workspacedisplaystatus_internal_test.go b/codersdk/workspacedisplaystatus_internal_test.go index 31767dabfe2f5..68e718a5f4cde 100644 --- a/codersdk/workspacedisplaystatus_internal_test.go +++ b/codersdk/workspacedisplaystatus_internal_test.go @@ -90,7 +90,6 @@ func TestWorkspaceDisplayStatus(t *testing.T) { }, } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() if got := WorkspaceDisplayStatus(tt.jobStatus, tt.transition); got != tt.want { diff --git a/cryptorand/strings_test.go b/cryptorand/strings_test.go index 6fce5752d68f3..4a24f907a2dc8 100644 --- a/cryptorand/strings_test.go +++ b/cryptorand/strings_test.go @@ -92,7 +92,6 @@ func TestStringCharset(t *testing.T) { } for _, test := range tests { - t.Run(test.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/audit/audit_test.go b/enterprise/audit/audit_test.go index 5c44d40768307..bf9393612d65c 100644 --- a/enterprise/audit/audit_test.go +++ b/enterprise/audit/audit_test.go @@ -84,7 +84,6 @@ func TestAuditor(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/audit/diff_internal_test.go b/enterprise/audit/diff_internal_test.go index c946019c205ee..afbd1b37844cc 100644 --- a/enterprise/audit/diff_internal_test.go +++ b/enterprise/audit/diff_internal_test.go @@ -417,7 +417,6 @@ func runDiffTests(t *testing.T, tests []diffTest) { t.Helper() for _, test := range tests { - typName := reflect.TypeOf(test.left).Name() t.Run(typName+"/"+test.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/cli/start_test.go b/enterprise/cli/start_test.go index d442742d96c6d..b68a95ae1131d 100644 --- a/enterprise/cli/start_test.go +++ b/enterprise/cli/start_test.go @@ -121,11 +121,9 @@ func TestStart(t *testing.T) { } for _, cmd := range []string{"start", "restart"} { - t.Run(cmd, func(t *testing.T) { t.Parallel() for _, c := range cases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/authorize_test.go b/enterprise/coderd/authorize_test.go index 1d3fec95c3040..d64cdb58c2e8e 100644 --- a/enterprise/coderd/authorize_test.go +++ b/enterprise/coderd/authorize_test.go @@ -96,7 +96,6 @@ func TestCheckACLPermissions(t *testing.T) { } for _, c := range testCases { - t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/coderd_test.go b/enterprise/coderd/coderd_test.go index dccb0028cfdf6..1c8c863db040b 100644 --- a/enterprise/coderd/coderd_test.go +++ b/enterprise/coderd/coderd_test.go @@ -292,7 +292,6 @@ func TestEntitlements_Prebuilds(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() @@ -617,7 +616,6 @@ func TestSCIMDisabled(t *testing.T) { } for _, p := range checkPaths { - t.Run(p, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/enidpsync/organizations_test.go b/enterprise/coderd/enidpsync/organizations_test.go index 5372b1329bf1c..d2a5aafece558 100644 --- a/enterprise/coderd/enidpsync/organizations_test.go +++ b/enterprise/coderd/enidpsync/organizations_test.go @@ -296,7 +296,6 @@ func TestOrganizationSync(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitMedium) diff --git a/enterprise/coderd/httpmw/provisionerdaemon_test.go b/enterprise/coderd/httpmw/provisionerdaemon_test.go index c7ff5bad357aa..4d9575c72491a 100644 --- a/enterprise/coderd/httpmw/provisionerdaemon_test.go +++ b/enterprise/coderd/httpmw/provisionerdaemon_test.go @@ -126,7 +126,6 @@ func TestExtractProvisionerDaemonAuthenticated(t *testing.T) { } for _, test := range tests { - t.Run(test.name, func(t *testing.T) { t.Parallel() routeCtx := chi.NewRouteContext() diff --git a/enterprise/coderd/insights_test.go b/enterprise/coderd/insights_test.go index ae890a21db868..d38eefc593926 100644 --- a/enterprise/coderd/insights_test.go +++ b/enterprise/coderd/insights_test.go @@ -34,7 +34,6 @@ func TestTemplateInsightsWithTemplateAdminACL(t *testing.T) { } for _, tt := range tests { - t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) { t.Parallel() @@ -94,7 +93,6 @@ func TestTemplateInsightsWithRole(t *testing.T) { } for _, tt := range tests { - t.Run(fmt.Sprintf("with interval=%q role=%q", tt.interval, tt.role), func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/license/license_test.go b/enterprise/coderd/license/license_test.go index 9ef12aa58f88e..bf6d6448205e0 100644 --- a/enterprise/coderd/license/license_test.go +++ b/enterprise/coderd/license/license_test.go @@ -848,7 +848,6 @@ func TestLicenseEntitlements(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/claim_test.go b/enterprise/coderd/prebuilds/claim_test.go index c255490379427..ec1d6dbbd5a98 100644 --- a/enterprise/coderd/prebuilds/claim_test.go +++ b/enterprise/coderd/prebuilds/claim_test.go @@ -128,7 +128,6 @@ func TestClaimPrebuild(t *testing.T) { for name, tc := range cases { // Ensure that prebuilt workspaces can be claimed in non-default organizations: for _, useDefaultOrg := range []bool{true, false} { - t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/membership_test.go b/enterprise/coderd/prebuilds/membership_test.go index c11de4c03345b..233d44855886a 100644 --- a/enterprise/coderd/prebuilds/membership_test.go +++ b/enterprise/coderd/prebuilds/membership_test.go @@ -57,7 +57,6 @@ func TestReconcileAll(t *testing.T) { } for _, tc := range tests { - // capture t.Run(tc.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/prebuilds/metricscollector_test.go b/enterprise/coderd/prebuilds/metricscollector_test.go index 7f37a59880f4d..d8290174209e8 100644 --- a/enterprise/coderd/prebuilds/metricscollector_test.go +++ b/enterprise/coderd/prebuilds/metricscollector_test.go @@ -177,19 +177,12 @@ func TestMetricsCollector(t *testing.T) { }, } for _, test := range tests { - // capture for parallel for _, transition := range test.transitions { - // capture for parallel for _, jobStatus := range test.jobStatuses { - // capture for parallel for _, initiatorID := range test.initiatorIDs { - // capture for parallel for _, ownerID := range test.ownerIDs { - // capture for parallel for _, templateDeleted := range test.templateDeleted { - // capture for parallel for _, eligible := range test.eligible { - // capture for parallel t.Run(fmt.Sprintf("%v/transition:%s/jobStatus:%s", test.name, transition, jobStatus), func(t *testing.T) { t.Parallel() @@ -260,7 +253,6 @@ func TestMetricsCollector(t *testing.T) { require.Equal(t, 1, len(presets)) for _, preset := range presets { - // capture for parallel labels := map[string]string{ "template_name": template.Name, "preset_name": preset.Name, diff --git a/enterprise/coderd/prebuilds/reconcile_test.go b/enterprise/coderd/prebuilds/reconcile_test.go index ce866a81f5d8b..39271db83b25a 100644 --- a/enterprise/coderd/prebuilds/reconcile_test.go +++ b/enterprise/coderd/prebuilds/reconcile_test.go @@ -309,7 +309,6 @@ func TestPrebuildReconciliation(t *testing.T) { }, } for _, tc := range testCases { - // capture for parallel for _, templateVersionActive := range tc.templateVersionActive { for _, prebuildLatestTransition := range tc.prebuildLatestTransitions { for _, prebuildJobStatus := range tc.prebuildJobStatuses { diff --git a/enterprise/coderd/provisionerdaemons_test.go b/enterprise/coderd/provisionerdaemons_test.go index 85c7e62d0ac4c..a94a60ffff3c2 100644 --- a/enterprise/coderd/provisionerdaemons_test.go +++ b/enterprise/coderd/provisionerdaemons_test.go @@ -921,7 +921,6 @@ func TestGetProvisionerDaemons(t *testing.T) { }, } for _, tt := range testCases { - t.Run(tt.name, func(t *testing.T) { t.Parallel() dv := coderdtest.DeploymentValues(t) diff --git a/enterprise/coderd/provisionerkeys_test.go b/enterprise/coderd/provisionerkeys_test.go index 97e4eccf1fa63..daca6625d620f 100644 --- a/enterprise/coderd/provisionerkeys_test.go +++ b/enterprise/coderd/provisionerkeys_test.go @@ -167,7 +167,6 @@ func TestGetProvisionerKey(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/proxyhealth/proxyhealth.go b/enterprise/coderd/proxyhealth/proxyhealth.go index 0b6f3ed666939..ef721841362c8 100644 --- a/enterprise/coderd/proxyhealth/proxyhealth.go +++ b/enterprise/coderd/proxyhealth/proxyhealth.go @@ -240,7 +240,6 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID } // Each proxy needs to have a status set. Make a local copy for the // call to be run async. - status := ProxyStatus{ Proxy: proxy, CheckedAt: now, diff --git a/enterprise/coderd/roles_test.go b/enterprise/coderd/roles_test.go index 82bc5e0c8329f..70c432755f7fa 100644 --- a/enterprise/coderd/roles_test.go +++ b/enterprise/coderd/roles_test.go @@ -517,7 +517,6 @@ func TestListRoles(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/schedule/template_test.go b/enterprise/coderd/schedule/template_test.go index c400f85ff69bc..4af06042b031f 100644 --- a/enterprise/coderd/schedule/template_test.go +++ b/enterprise/coderd/schedule/template_test.go @@ -191,7 +191,6 @@ func TestTemplateUpdateBuildDeadlines(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -777,7 +776,6 @@ func TestTemplateTTL(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/templates_test.go b/enterprise/coderd/templates_test.go index 8cb972e847ef7..6c7a20f85a642 100644 --- a/enterprise/coderd/templates_test.go +++ b/enterprise/coderd/templates_test.go @@ -470,7 +470,6 @@ func TestTemplates(t *testing.T) { } for _, c := range cases { - // nolint: paralleltest // context is from parent t.Run t.Run(c.Name, func(t *testing.T) { _, err := anotherClient.UpdateTemplateMeta(ctx, template.ID, codersdk.UpdateTemplateMeta{ diff --git a/enterprise/coderd/userauth_test.go b/enterprise/coderd/userauth_test.go index e6166bc847977..46207f319dbe1 100644 --- a/enterprise/coderd/userauth_test.go +++ b/enterprise/coderd/userauth_test.go @@ -902,7 +902,6 @@ func TestGroupSync(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() runner := setupOIDCTest(t, oidcTestConfig{ diff --git a/enterprise/coderd/users_test.go b/enterprise/coderd/users_test.go index aacafef72ef8a..7cfef59fa9e5f 100644 --- a/enterprise/coderd/users_test.go +++ b/enterprise/coderd/users_test.go @@ -426,7 +426,6 @@ func TestGrantSiteRoles(t *testing.T) { } for _, c := range testCases { - t.Run(c.Name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitLong) diff --git a/enterprise/coderd/workspaceproxy_internal_test.go b/enterprise/coderd/workspaceproxy_internal_test.go index 5e202d53dd0bb..1bb84b4026ca6 100644 --- a/enterprise/coderd/workspaceproxy_internal_test.go +++ b/enterprise/coderd/workspaceproxy_internal_test.go @@ -47,7 +47,6 @@ func Test_validateProxyURL(t *testing.T) { } for _, tt := range testcases { - t.Run(tt.Name, func(t *testing.T) { t.Parallel() diff --git a/enterprise/coderd/workspaces_test.go b/enterprise/coderd/workspaces_test.go index 1334ac1d80c10..eb1e3c0a554b0 100644 --- a/enterprise/coderd/workspaces_test.go +++ b/enterprise/coderd/workspaces_test.go @@ -1953,7 +1953,6 @@ func TestWorkspaceTagsTerraform(t *testing.T) { }`, }, } { - t.Run(tc.name, func(t *testing.T) { client, owner := coderdenttest.New(t, &coderdenttest.Options{ Options: &coderdtest.Options{ diff --git a/enterprise/provisionerd/remoteprovisioners_test.go b/enterprise/provisionerd/remoteprovisioners_test.go index 5360fe4e442c2..7b89d696ee20e 100644 --- a/enterprise/provisionerd/remoteprovisioners_test.go +++ b/enterprise/provisionerd/remoteprovisioners_test.go @@ -33,7 +33,6 @@ func TestRemoteConnector_Mainline(t *testing.T) { {name: "Smokescreen", smokescreen: true}, } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitMedium) diff --git a/enterprise/replicasync/replicasync.go b/enterprise/replicasync/replicasync.go index bf60740b7050f..c80ae3b7ac814 100644 --- a/enterprise/replicasync/replicasync.go +++ b/enterprise/replicasync/replicasync.go @@ -410,7 +410,6 @@ func (m *Manager) AllPrimary() []database.Replica { // When we assign the non-pointer to a // variable it loses the reference. - replicas = append(replicas, replica) } return replicas diff --git a/enterprise/wsproxy/wsproxy_test.go b/enterprise/wsproxy/wsproxy_test.go index bcffb642410a2..99cb5c60545f9 100644 --- a/enterprise/wsproxy/wsproxy_test.go +++ b/enterprise/wsproxy/wsproxy_test.go @@ -282,7 +282,6 @@ resourceLoop: // Connect to each region. for _, r := range connInfo.DERPMap.Regions { - if len(r.Nodes) == 1 && r.Nodes[0].STUNOnly { // Skip STUN-only regions. continue @@ -654,7 +653,6 @@ func TestWorkspaceProxyDERPMeshProbe(t *testing.T) { replicaPingDone = [count]bool{} ) for i := range proxies { - proxies[i] = coderdenttest.NewWorkspaceProxyReplica(t, api, client, &coderdenttest.ProxyOptions{ Name: "proxy-1", Token: sessionToken, diff --git a/examples/examples_test.go b/examples/examples_test.go index f279b063f9934..779835eec66d5 100644 --- a/examples/examples_test.go +++ b/examples/examples_test.go @@ -19,7 +19,6 @@ func TestTemplate(t *testing.T) { require.NoError(t, err, "error listing examples, run \"make gen\" to ensure examples are up to date") require.NotEmpty(t, list) for _, eg := range list { - t.Run(eg.ID, func(t *testing.T) { t.Parallel() assert.NotEmpty(t, eg.ID, "example ID should not be empty") diff --git a/helm/coder/tests/chart_test.go b/helm/coder/tests/chart_test.go index f1d3b19852137..a11d631a2f247 100644 --- a/helm/coder/tests/chart_test.go +++ b/helm/coder/tests/chart_test.go @@ -163,9 +163,7 @@ func TestRenderChart(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - for _, ns := range namespaces { - tc.namespace = ns t.Run(tc.namespace+"/"+tc.name, func(t *testing.T) { @@ -212,14 +210,12 @@ func TestUpdateGoldenFiles(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - if tc.expectedError != "" { t.Logf("skipping test case %q with render error", tc.name) continue } for _, ns := range namespaces { - tc.namespace = ns valuesPath := tc.valuesFilePath() diff --git a/helm/provisioner/tests/chart_test.go b/helm/provisioner/tests/chart_test.go index ffc841c98b3d8..8b0cc5cabaa1e 100644 --- a/helm/provisioner/tests/chart_test.go +++ b/helm/provisioner/tests/chart_test.go @@ -141,9 +141,7 @@ func TestRenderChart(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - for _, ns := range namespaces { - tc.namespace = ns t.Run(tc.namespace+"/"+tc.name, func(t *testing.T) { @@ -190,14 +188,12 @@ func TestUpdateGoldenFiles(t *testing.T) { require.NoError(t, err, "failed to build Helm dependencies") for _, tc := range testCases { - if tc.expectedError != "" { t.Logf("skipping test case %q with render error", tc.name) continue } for _, ns := range namespaces { - tc.namespace = ns valuesPath := tc.valuesFilePath() diff --git a/provisioner/terraform/diagnostic_test.go b/provisioner/terraform/diagnostic_test.go index 2cd76b0eca97c..0fd353ae540a5 100644 --- a/provisioner/terraform/diagnostic_test.go +++ b/provisioner/terraform/diagnostic_test.go @@ -47,7 +47,6 @@ func TestFormatDiagnostic(t *testing.T) { } for name, tc := range tests { - t.Run(name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/executor_internal_test.go b/provisioner/terraform/executor_internal_test.go index 90e85a5bf339a..a39d8758893b8 100644 --- a/provisioner/terraform/executor_internal_test.go +++ b/provisioner/terraform/executor_internal_test.go @@ -157,7 +157,6 @@ func TestOnlyDataResources(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/parse_test.go b/provisioner/terraform/parse_test.go index c83335d13da63..d2a505235f688 100644 --- a/provisioner/terraform/parse_test.go +++ b/provisioner/terraform/parse_test.go @@ -376,7 +376,6 @@ func TestParse(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/provision_test.go b/provisioner/terraform/provision_test.go index 48e8c1e198910..dc4545d137e89 100644 --- a/provisioner/terraform/provision_test.go +++ b/provisioner/terraform/provision_test.go @@ -312,7 +312,6 @@ func TestProvision_Cancel(t *testing.T) { }, } for _, tt := range tests { - // below we exec fake_cancel.sh, which causes the kernel to execute it, and if more than // one process tries to do this, it can cause "text file busy" // nolint: paralleltest @@ -1067,7 +1066,6 @@ func TestProvision(t *testing.T) { } for _, testCase := range testCases { - t.Run(testCase.Name, func(t *testing.T) { t.Parallel() diff --git a/provisioner/terraform/resources_test.go b/provisioner/terraform/resources_test.go index f202e157751e9..8e7e57ded1425 100644 --- a/provisioner/terraform/resources_test.go +++ b/provisioner/terraform/resources_test.go @@ -917,7 +917,6 @@ func TestConvertResources(t *testing.T) { }, }, } { - t.Run(folderName, func(t *testing.T) { t.Parallel() dir := filepath.Join(filepath.Dir(filename), "testdata", "resources", folderName) @@ -1100,7 +1099,6 @@ func TestAppSlugValidation(t *testing.T) { //nolint:paralleltest for i, c := range cases { - t.Run(fmt.Sprintf("case-%d", i), func(t *testing.T) { // Change the first app slug to match the current case. for _, resource := range tfPlan.PlannedValues.RootModule.Resources { @@ -1177,7 +1175,6 @@ func TestAgentNameInvalid(t *testing.T) { //nolint:paralleltest for i, c := range cases { - t.Run(fmt.Sprintf("case-%d", i), func(t *testing.T) { // Change the first agent name to match the current case. for _, resource := range tfPlan.PlannedValues.RootModule.Resources { @@ -1329,7 +1326,6 @@ func TestInstanceTypeAssociation(t *testing.T) { ResourceType: "azurerm_windows_virtual_machine", InstanceTypeKey: "size", }} { - t.Run(tc.ResourceType, func(t *testing.T) { t.Parallel() ctx, logger := ctxAndLogger(t) @@ -1388,7 +1384,6 @@ func TestInstanceIDAssociation(t *testing.T) { ResourceType: "azurerm_windows_virtual_machine", InstanceIDKey: "virtual_machine_id", }} { - t.Run(tc.ResourceType, func(t *testing.T) { t.Parallel() ctx, logger := ctxAndLogger(t) diff --git a/provisioner/terraform/tfparse/tfparse_test.go b/provisioner/terraform/tfparse/tfparse_test.go index 506778027efdd..41182b9aa2dac 100644 --- a/provisioner/terraform/tfparse/tfparse_test.go +++ b/provisioner/terraform/tfparse/tfparse_test.go @@ -587,7 +587,6 @@ func Test_WorkspaceTagDefaultsFromFile(t *testing.T) { expectTags: map[string]string{"foo": "bar", "a": "1"}, }, } { - t.Run(tc.name+"/tar", func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/provisionersdk/provisionertags_test.go b/provisionersdk/provisionertags_test.go index e91f264a5745b..070285aea6c50 100644 --- a/provisionersdk/provisionertags_test.go +++ b/provisionersdk/provisionertags_test.go @@ -185,7 +185,6 @@ func TestMutateTags(t *testing.T) { }, }, } { - t.Run(tt.name, func(t *testing.T) { t.Parallel() got := provisionersdk.MutateTags(tt.userID, tt.tags...) diff --git a/pty/ptytest/ptytest_test.go b/pty/ptytest/ptytest_test.go index 16c7d4ed924df..29011ba9e7e61 100644 --- a/pty/ptytest/ptytest_test.go +++ b/pty/ptytest/ptytest_test.go @@ -56,7 +56,6 @@ func TestPtytest(t *testing.T) { {name: "10241 large output", output: strings.Repeat(".", 10241)}, // 1024 * 10 + 1 } for _, tt := range tests { - // nolint:paralleltest // Avoid parallel test to more easily identify the issue. t.Run(tt.name, func(t *testing.T) { cmd := &serpent.Command{ diff --git a/scaletest/agentconn/config_test.go b/scaletest/agentconn/config_test.go index 456d300a442e2..412d7f6926119 100644 --- a/scaletest/agentconn/config_test.go +++ b/scaletest/agentconn/config_test.go @@ -167,7 +167,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/createworkspaces/config_test.go b/scaletest/createworkspaces/config_test.go index 86c0016dd9830..3965e9f9dfb69 100644 --- a/scaletest/createworkspaces/config_test.go +++ b/scaletest/createworkspaces/config_test.go @@ -63,7 +63,6 @@ func Test_UserConfig(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() @@ -176,7 +175,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/harness/strategies.go b/scaletest/harness/strategies.go index 4892398e9dbe6..7d5067a4e1eb3 100644 --- a/scaletest/harness/strategies.go +++ b/scaletest/harness/strategies.go @@ -122,7 +122,6 @@ var _ ExecutionStrategy = TimeoutExecutionStrategyWrapper{} func (t TimeoutExecutionStrategyWrapper) Run(ctx context.Context, fns []TestFn) ([]error, error) { newFns := make([]TestFn, len(fns)) for i, fn := range fns { - newFns[i] = func(ctx context.Context) error { ctx, cancel := context.WithTimeout(ctx, t.Timeout) defer cancel() diff --git a/scaletest/harness/strategies_test.go b/scaletest/harness/strategies_test.go index 691b20bcc13eb..b18036a7931d3 100644 --- a/scaletest/harness/strategies_test.go +++ b/scaletest/harness/strategies_test.go @@ -186,7 +186,6 @@ func strategyTestData(count int, runFn func(ctx context.Context, i int, logs io. fns = make([]harness.TestFn, count) ) for i := 0; i < count; i++ { - runs[i] = harness.NewTestRun("test", strconv.Itoa(i), testFns{ RunFn: func(ctx context.Context, id string, logs io.Writer) error { if runFn != nil { diff --git a/scaletest/placebo/config_test.go b/scaletest/placebo/config_test.go index b0bd82a4658a8..84458c28a8d8e 100644 --- a/scaletest/placebo/config_test.go +++ b/scaletest/placebo/config_test.go @@ -98,7 +98,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/reconnectingpty/config_test.go b/scaletest/reconnectingpty/config_test.go index 76822046b5418..1b7646ad744d9 100644 --- a/scaletest/reconnectingpty/config_test.go +++ b/scaletest/reconnectingpty/config_test.go @@ -61,7 +61,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scaletest/workspacebuild/config_test.go b/scaletest/workspacebuild/config_test.go index 268e152d831e0..c80b48df9055c 100644 --- a/scaletest/workspacebuild/config_test.go +++ b/scaletest/workspacebuild/config_test.go @@ -78,7 +78,6 @@ func Test_Config(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() diff --git a/scripts/apitypings/main_test.go b/scripts/apitypings/main_test.go index e515fffff7f50..1bb89c7ba5423 100644 --- a/scripts/apitypings/main_test.go +++ b/scripts/apitypings/main_test.go @@ -31,7 +31,6 @@ func TestGeneration(t *testing.T) { // Only test directories continue } - t.Run(f.Name(), func(t *testing.T) { t.Parallel() dir := filepath.Join(".", "testdata", f.Name()) diff --git a/scripts/release/main_internal_test.go b/scripts/release/main_internal_test.go index 3557673b3ab66..587d327272af5 100644 --- a/scripts/release/main_internal_test.go +++ b/scripts/release/main_internal_test.go @@ -115,7 +115,6 @@ Enjoy. } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() if diff := cmp.Diff(removeMainlineBlurb(tt.body), tt.want); diff != "" { @@ -167,7 +166,6 @@ func Test_release_autoversion(t *testing.T) { require.NoError(t, err) for _, file := range files { - t.Run(file, func(t *testing.T) { t.Parallel() diff --git a/scripts/releasemigrations/main.go b/scripts/releasemigrations/main.go index cc924565231b4..249d1891f9c29 100644 --- a/scripts/releasemigrations/main.go +++ b/scripts/releasemigrations/main.go @@ -230,7 +230,6 @@ func hasMigrationDiff(dir string, a, b string) ([]string, error) { migrations := strings.Split(strings.TrimSpace(string(output)), "\n") filtered := make([]string, 0, len(migrations)) for _, migration := range migrations { - if strings.Contains(migration, "fixtures") { continue } diff --git a/scripts/typegen/main.go b/scripts/typegen/main.go index 8a94d4ff447df..acbaa9c2c35fe 100644 --- a/scripts/typegen/main.go +++ b/scripts/typegen/main.go @@ -243,7 +243,6 @@ func generateRbacObjects(templateSource string) ([]byte, error) { var out bytes.Buffer list := make([]Definition, 0) for t, v := range policy.RBACPermissions { - list = append(list, Definition{ PermissionDefinition: v, Type: t, diff --git a/site/site.go b/site/site.go index 10639977ecfb3..3932eb3ffac15 100644 --- a/site/site.go +++ b/site/site.go @@ -823,7 +823,6 @@ func verifyBinSha1IsCurrent(dest string, siteFS fs.FS, shaFiles map[string]strin // Verify the hash of each on-disk binary. for file, hash1 := range shaFiles { - eg.Go(func() error { hash2, err := sha1HashFile(filepath.Join(dest, file)) if err != nil { diff --git a/site/site_test.go b/site/site_test.go index 4dfd97aaa3a26..f7301debba2be 100644 --- a/site/site_test.go +++ b/site/site_test.go @@ -498,7 +498,6 @@ func TestServingBin(t *testing.T) { } //nolint // Parallel test detection issue. for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/tailnet/configmaps_internal_test.go b/tailnet/configmaps_internal_test.go index b9d424287a566..169dd05d8cccc 100644 --- a/tailnet/configmaps_internal_test.go +++ b/tailnet/configmaps_internal_test.go @@ -1116,7 +1116,6 @@ func TestConfigMaps_updatePeers_nonexist(t *testing.T) { proto.CoordinateResponse_PeerUpdate_DISCONNECTED, proto.CoordinateResponse_PeerUpdate_LOST, } { - t.Run(k.String(), func(t *testing.T) { t.Parallel() ctx := testutil.Context(t, testutil.WaitShort) diff --git a/tailnet/convert_test.go b/tailnet/convert_test.go index 2d1eb5569f891..72290cfba472e 100644 --- a/tailnet/convert_test.go +++ b/tailnet/convert_test.go @@ -64,7 +64,6 @@ func TestNode(t *testing.T) { } for _, tc := range testCases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() p, err := tailnet.NodeToProto(&tc.node) diff --git a/tailnet/telemetry_internal_test.go b/tailnet/telemetry_internal_test.go index 2d23b72e83faf..30c2a5b77d5f8 100644 --- a/tailnet/telemetry_internal_test.go +++ b/tailnet/telemetry_internal_test.go @@ -121,7 +121,6 @@ func TestTelemetryStore(t *testing.T) { } for _, c := range cases { - t.Run(c.name, func(t *testing.T) { t.Parallel() telemetry, err := newTelemetryStore() diff --git a/vpn/tunnel_internal_test.go b/vpn/tunnel_internal_test.go index ab3a6c55da43d..c21fd20251282 100644 --- a/vpn/tunnel_internal_test.go +++ b/vpn/tunnel_internal_test.go @@ -1153,7 +1153,6 @@ func TestProcessFreshState(t *testing.T) { } for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { t.Parallel() diff --git a/vpn/version_test.go b/vpn/version_test.go index 8b6e366e1f632..442aa66c85279 100644 --- a/vpn/version_test.go +++ b/vpn/version_test.go @@ -175,7 +175,6 @@ func TestRPCVersionListParseString(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() got, err := vpn.ParseRPCVersionList(tc.input) @@ -248,7 +247,6 @@ func TestRPCVersionListValidate(t *testing.T) { } for _, tc := range cases { - t.Run(tc.name, func(t *testing.T) { t.Parallel() err := tc.list.Validate() From c5ea297a4fd9b6f7f0a728a90c2bcf734f2991d4 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Wed, 18 Jun 2025 22:07:48 +0000 Subject: [PATCH 3/4] remove comment cian spotted --- enterprise/replicasync/replicasync.go | 2 -- 1 file changed, 2 deletions(-) diff --git a/enterprise/replicasync/replicasync.go b/enterprise/replicasync/replicasync.go index c80ae3b7ac814..528540a262464 100644 --- a/enterprise/replicasync/replicasync.go +++ b/enterprise/replicasync/replicasync.go @@ -408,8 +408,6 @@ func (m *Manager) AllPrimary() []database.Replica { continue } - // When we assign the non-pointer to a - // variable it loses the reference. replicas = append(replicas, replica) } return replicas From 835331352bc641e0dc05a571b469129131b0b5d7 Mon Sep 17 00:00:00 2001 From: McKayla Washburn Date: Fri, 20 Jun 2025 18:45:28 +0000 Subject: [PATCH 4/4] revert non-test files --- agent/agent.go | 2 ++ agent/agentscripts/agentscripts.go | 2 ++ cli/organizationroles.go | 1 + cli/organizationsettings.go | 2 ++ cli/server.go | 13 ++++----- coderd/database/pubsub/pubsub_memory.go | 1 + coderd/externalauth/externalauth.go | 2 ++ coderd/idpsync/group.go | 4 +++ coderd/rbac/authz.go | 1 + coderd/rbac/roles.go | 27 +++++++++++++------ coderd/webpush/webpush.go | 1 + enterprise/coderd/proxyhealth/proxyhealth.go | 1 + enterprise/replicasync/replicasync.go | 3 +++ site/site.go | 28 ++++++++++++++++++++ 14 files changed, 74 insertions(+), 14 deletions(-) diff --git a/agent/agent.go b/agent/agent.go index d417d93ef166d..e142f8662f641 100644 --- a/agent/agent.go +++ b/agent/agent.go @@ -547,6 +547,7 @@ func (a *agent) reportMetadata(ctx context.Context, aAPI proto.DRPCAgentClient26 // channel to synchronize the results and avoid both messy // mutex logic and overloading the API. for _, md := range manifest.Metadata { + md := md // We send the result to the channel in the goroutine to avoid // sending the same result multiple times. So, we don't care about // the return values. @@ -1296,6 +1297,7 @@ func (a *agent) updateCommandEnv(current []string) (updated []string, err error) "CODER": "true", "CODER_WORKSPACE_NAME": manifest.WorkspaceName, "CODER_WORKSPACE_AGENT_NAME": manifest.AgentName, + "CODER_WORKSPACE_OWNER_NAME": manifest.OwnerName, // Specific Coder subcommands require the agent token exposed! "CODER_AGENT_TOKEN": *a.sessionToken.Load(), diff --git a/agent/agentscripts/agentscripts.go b/agent/agentscripts/agentscripts.go index 1dfcde8adb009..79606a80233b9 100644 --- a/agent/agentscripts/agentscripts.go +++ b/agent/agentscripts/agentscripts.go @@ -177,6 +177,7 @@ func (r *Runner) Init(scripts []codersdk.WorkspaceAgentScript, scriptCompleted S if script.Cron == "" { continue } + script := script _, err := r.cron.AddFunc(script.Cron, func() { err := r.trackRun(r.cronCtx, script.WorkspaceAgentScript, ExecuteCronScripts) if err != nil { @@ -253,6 +254,7 @@ func (r *Runner) Execute(ctx context.Context, option ExecuteOption) error { continue } + script := script eg.Go(func() error { err := r.trackRun(ctx, script.WorkspaceAgentScript, option) if err != nil { diff --git a/cli/organizationroles.go b/cli/organizationroles.go index 3651baea88d2f..4d68ab02ae78d 100644 --- a/cli/organizationroles.go +++ b/cli/organizationroles.go @@ -435,6 +435,7 @@ func applyOrgResourceActions(role *codersdk.Role, resource string, actions []str // Construct new site perms with only new perms for the resource keep := make([]codersdk.Permission, 0) for _, perm := range role.OrganizationPermissions { + perm := perm if string(perm.ResourceType) != resource { keep = append(keep, perm) } diff --git a/cli/organizationsettings.go b/cli/organizationsettings.go index 391a4f72e27fd..920ae41ebe1fc 100644 --- a/cli/organizationsettings.go +++ b/cli/organizationsettings.go @@ -116,6 +116,7 @@ func (r *RootCmd) setOrganizationSettings(orgContext *OrganizationContext, setti } for _, set := range settings { + set := set patch := set.Patch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, @@ -191,6 +192,7 @@ func (r *RootCmd) printOrganizationSetting(orgContext *OrganizationContext, sett } for _, set := range settings { + set := set fetch := set.Fetch cmd.Children = append(cmd.Children, &serpent.Command{ Use: set.Name, diff --git a/cli/server.go b/cli/server.go index a5f8277576bdf..7d587f5e1ae14 100644 --- a/cli/server.go +++ b/cli/server.go @@ -1202,6 +1202,7 @@ func (r *RootCmd) Server(newAPI func(context.Context, *coderd.Options) (*coderd. var wg sync.WaitGroup for i, provisionerDaemon := range provisionerDaemons { id := i + 1 + provisionerDaemon := provisionerDaemon wg.Add(1) go func() { defer wg.Done() @@ -1679,6 +1680,7 @@ func configureServerTLS(ctx context.Context, logger slog.Logger, tlsMinVersion, // Expensively check which certificate matches the client hello. for _, cert := range certs { + cert := cert if err := hi.SupportsCertificate(&cert); err == nil { return &cert, nil } @@ -2310,19 +2312,20 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d var err error var sqlDB *sql.DB + dbNeedsClosing := true // Try to connect for 30 seconds. ctx, cancel := context.WithTimeout(ctx, 30*time.Second) defer cancel() defer func() { - if err == nil { + if !dbNeedsClosing { return } if sqlDB != nil { _ = sqlDB.Close() sqlDB = nil + logger.Debug(ctx, "closed db before returning from ConnectToPostgres") } - logger.Error(ctx, "connect to postgres failed", slog.Error(err)) }() var tries int @@ -2358,11 +2361,8 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d return nil, xerrors.Errorf("get postgres version: %w", err) } defer version.Close() - if version.Err() != nil { - return nil, xerrors.Errorf("version select: %w", version.Err()) - } if !version.Next() { - return nil, xerrors.Errorf("no rows returned for version select") + return nil, xerrors.Errorf("no rows returned for version select: %w", version.Err()) } var versionNum int err = version.Scan(&versionNum) @@ -2404,6 +2404,7 @@ func ConnectToPostgres(ctx context.Context, logger slog.Logger, driver string, d // of connection churn. sqlDB.SetMaxIdleConns(3) + dbNeedsClosing = false return sqlDB, nil } diff --git a/coderd/database/pubsub/pubsub_memory.go b/coderd/database/pubsub/pubsub_memory.go index 59a5730ff9808..c4766c3dfa3fb 100644 --- a/coderd/database/pubsub/pubsub_memory.go +++ b/coderd/database/pubsub/pubsub_memory.go @@ -73,6 +73,7 @@ func (m *MemoryPubsub) Publish(event string, message []byte) error { var wg sync.WaitGroup for _, listener := range listeners { wg.Add(1) + listener := listener go func() { defer wg.Done() listener.send(context.Background(), message) diff --git a/coderd/externalauth/externalauth.go b/coderd/externalauth/externalauth.go index 9b8b87748e784..600aacf62f7dd 100644 --- a/coderd/externalauth/externalauth.go +++ b/coderd/externalauth/externalauth.go @@ -505,6 +505,8 @@ func ConvertConfig(instrument *promoauth.Factory, entries []codersdk.ExternalAut ids := map[string]struct{}{} configs := []*Config{} for _, entry := range entries { + entry := entry + // Applies defaults to the config entry. // This allows users to very simply state that they type is "GitHub", // apply their client secret and ID, and have the UI appear nicely. diff --git a/coderd/idpsync/group.go b/coderd/idpsync/group.go index 0b21c5b9ac84c..b5d8003165665 100644 --- a/coderd/idpsync/group.go +++ b/coderd/idpsync/group.go @@ -99,6 +99,7 @@ func (s AGPLIDPSync) SyncGroups(ctx context.Context, db database.Store, user dat // membership via the groups the user is in. userOrgs := make(map[uuid.UUID][]database.GetGroupsRow) for _, g := range userGroups { + g := g userOrgs[g.Group.OrganizationID] = append(userOrgs[g.Group.OrganizationID], g) } @@ -336,6 +337,8 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai groups := make([]ExpectedGroup, 0) for _, group := range parsedGroups { + group := group + // Legacy group mappings happen before the regex filter. mappedGroupName, ok := s.LegacyNameMapping[group] if ok { @@ -352,6 +355,7 @@ func (s GroupSyncSettings) ParseClaims(orgID uuid.UUID, mergedClaims jwt.MapClai mappedGroupIDs, ok := s.Mapping[group] if ok { for _, gid := range mappedGroupIDs { + gid := gid groups = append(groups, ExpectedGroup{OrganizationID: orgID, GroupID: &gid}) } continue diff --git a/coderd/rbac/authz.go b/coderd/rbac/authz.go index f57ed2585c068..a7f77d57ab253 100644 --- a/coderd/rbac/authz.go +++ b/coderd/rbac/authz.go @@ -760,6 +760,7 @@ func rbacTraceAttributes(actor Subject, action policy.Action, objectType string, uniqueRoleNames := actor.SafeRoleNames() roleStrings := make([]string, 0, len(uniqueRoleNames)) for _, roleName := range uniqueRoleNames { + roleName := roleName roleStrings = append(roleStrings, roleName.String()) } return trace.WithAttributes( diff --git a/coderd/rbac/roles.go b/coderd/rbac/roles.go index db26d62cec7e9..8acdf7486ddd2 100644 --- a/coderd/rbac/roles.go +++ b/coderd/rbac/roles.go @@ -270,11 +270,15 @@ func ReloadBuiltinRoles(opts *RoleOptions) { Site: append( // Workspace dormancy and workspace are omitted. // Workspace is specifically handled based on the opts.NoOwnerWorkspaceExec - allPermsExcept(ResourceWorkspaceDormant, ResourceWorkspace), + allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceWorkspace), // This adds back in the Workspace permissions. Permissions(map[string][]policy.Action{ ResourceWorkspace.Type: ownerWorkspaceActions, ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, + // PrebuiltWorkspaces are a subset of Workspaces. + // Explicitly setting PrebuiltWorkspace permissions for clarity. + // Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions. + ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, })...), Org: map[string][]Permission{}, User: []Permission{}, @@ -290,7 +294,7 @@ func ReloadBuiltinRoles(opts *RoleOptions) { ResourceWorkspaceProxy.Type: {policy.ActionRead}, }), Org: map[string][]Permission{}, - User: append(allPermsExcept(ResourceWorkspaceDormant, ResourceUser, ResourceOrganizationMember), + User: append(allPermsExcept(ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceUser, ResourceOrganizationMember), Permissions(map[string][]policy.Action{ // Reduced permission set on dormant workspaces. No build, ssh, or exec ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, @@ -335,8 +339,9 @@ func ReloadBuiltinRoles(opts *RoleOptions) { ResourceAssignOrgRole.Type: {policy.ActionRead}, ResourceTemplate.Type: ResourceTemplate.AvailableActions(), // CRUD all files, even those they did not upload. - ResourceFile.Type: {policy.ActionCreate, policy.ActionRead}, - ResourceWorkspace.Type: {policy.ActionRead}, + ResourceFile.Type: {policy.ActionCreate, policy.ActionRead}, + ResourceWorkspace.Type: {policy.ActionRead}, + ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, // CRUD to provisioner daemons for now. ResourceProvisionerDaemon.Type: {policy.ActionCreate, policy.ActionRead, policy.ActionUpdate, policy.ActionDelete}, // Needs to read all organizations since @@ -413,9 +418,13 @@ func ReloadBuiltinRoles(opts *RoleOptions) { }), Org: map[string][]Permission{ // Org admins should not have workspace exec perms. - organizationID.String(): append(allPermsExcept(ResourceWorkspace, ResourceWorkspaceDormant, ResourceAssignRole), Permissions(map[string][]policy.Action{ + organizationID.String(): append(allPermsExcept(ResourceWorkspace, ResourceWorkspaceDormant, ResourcePrebuiltWorkspace, ResourceAssignRole), Permissions(map[string][]policy.Action{ ResourceWorkspaceDormant.Type: {policy.ActionRead, policy.ActionDelete, policy.ActionCreate, policy.ActionUpdate, policy.ActionWorkspaceStop, policy.ActionCreateAgent, policy.ActionDeleteAgent}, ResourceWorkspace.Type: slice.Omit(ResourceWorkspace.AvailableActions(), policy.ActionApplicationConnect, policy.ActionSSH), + // PrebuiltWorkspaces are a subset of Workspaces. + // Explicitly setting PrebuiltWorkspace permissions for clarity. + // Note: even without PrebuiltWorkspace permissions, access is still granted via Workspace permissions. + ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, })...), }, User: []Permission{}, @@ -493,9 +502,10 @@ func ReloadBuiltinRoles(opts *RoleOptions) { Site: []Permission{}, Org: map[string][]Permission{ organizationID.String(): Permissions(map[string][]policy.Action{ - ResourceTemplate.Type: ResourceTemplate.AvailableActions(), - ResourceFile.Type: {policy.ActionCreate, policy.ActionRead}, - ResourceWorkspace.Type: {policy.ActionRead}, + ResourceTemplate.Type: ResourceTemplate.AvailableActions(), + ResourceFile.Type: {policy.ActionCreate, policy.ActionRead}, + ResourceWorkspace.Type: {policy.ActionRead}, + ResourcePrebuiltWorkspace.Type: {policy.ActionUpdate, policy.ActionDelete}, // Assigning template perms requires this permission. ResourceOrganization.Type: {policy.ActionRead}, ResourceOrganizationMember.Type: {policy.ActionRead}, @@ -837,6 +847,7 @@ func Permissions(perms map[string][]policy.Action) []Permission { list := make([]Permission, 0, len(perms)) for k, actions := range perms { for _, act := range actions { + act := act list = append(list, Permission{ Negate: false, ResourceType: k, diff --git a/coderd/webpush/webpush.go b/coderd/webpush/webpush.go index 0f54a269cad00..eb35685402c21 100644 --- a/coderd/webpush/webpush.go +++ b/coderd/webpush/webpush.go @@ -103,6 +103,7 @@ func (n *Webpusher) Dispatch(ctx context.Context, userID uuid.UUID, msg codersdk var mu sync.Mutex var eg errgroup.Group for _, subscription := range subscriptions { + subscription := subscription eg.Go(func() error { // TODO: Implement some retry logic here. For now, this is just a // best-effort attempt. diff --git a/enterprise/coderd/proxyhealth/proxyhealth.go b/enterprise/coderd/proxyhealth/proxyhealth.go index ef721841362c8..7faac6a9e8147 100644 --- a/enterprise/coderd/proxyhealth/proxyhealth.go +++ b/enterprise/coderd/proxyhealth/proxyhealth.go @@ -240,6 +240,7 @@ func (p *ProxyHealth) runOnce(ctx context.Context, now time.Time) (map[uuid.UUID } // Each proxy needs to have a status set. Make a local copy for the // call to be run async. + proxy := proxy status := ProxyStatus{ Proxy: proxy, CheckedAt: now, diff --git a/enterprise/replicasync/replicasync.go b/enterprise/replicasync/replicasync.go index 528540a262464..0a60ccfd0a1fc 100644 --- a/enterprise/replicasync/replicasync.go +++ b/enterprise/replicasync/replicasync.go @@ -408,6 +408,9 @@ func (m *Manager) AllPrimary() []database.Replica { continue } + // When we assign the non-pointer to a + // variable it loses the reference. + replica := replica replicas = append(replicas, replica) } return replicas diff --git a/site/site.go b/site/site.go index 3932eb3ffac15..0a97b4a78d2cb 100644 --- a/site/site.go +++ b/site/site.go @@ -85,6 +85,7 @@ type Options struct { Entitlements *entitlements.Set Telemetry telemetry.Reporter Logger slog.Logger + HideAITasks bool } func New(opts *Options) *Handler { @@ -316,6 +317,8 @@ type htmlState struct { Experiments string Regions string DocsURL string + + TasksTabVisible string } type csrfState struct { @@ -445,6 +448,7 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht var user database.User var themePreference string var terminalFont string + var tasksTabVisible bool orgIDs := []uuid.UUID{} eg.Go(func() error { var err error @@ -480,6 +484,20 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht orgIDs = memberIDs[0].OrganizationIDs return err }) + eg.Go(func() error { + // If HideAITasks is true, force hide the tasks tab + if h.opts.HideAITasks { + tasksTabVisible = false + return nil + } + + hasAITask, err := h.opts.Database.HasTemplateVersionsWithAITask(ctx) + if err != nil { + return err + } + tasksTabVisible = hasAITask + return nil + }) err := eg.Wait() if err == nil { var wg sync.WaitGroup @@ -550,6 +568,14 @@ func (h *Handler) renderHTMLWithState(r *http.Request, filePath string, state ht } }() } + wg.Add(1) + go func() { + defer wg.Done() + tasksTabVisible, err := json.Marshal(tasksTabVisible) + if err == nil { + state.TasksTabVisible = html.EscapeString(string(tasksTabVisible)) + } + }() wg.Wait() } @@ -823,6 +849,8 @@ func verifyBinSha1IsCurrent(dest string, siteFS fs.FS, shaFiles map[string]strin // Verify the hash of each on-disk binary. for file, hash1 := range shaFiles { + file := file + hash1 := hash1 eg.Go(func() error { hash2, err := sha1HashFile(filepath.Join(dest, file)) if err != nil {