chore: remove unnecessary redeclarations in for loops (#18440)

This commit is contained in:
ケイラ
2025-06-20 13:16:55 -06:00
committed by GitHub
parent 4fe0a4bca2
commit fae30a00fd
200 changed files with 0 additions and 431 deletions
-12
View File
@@ -130,7 +130,6 @@ func TestAgent_Stats_SSH(t *testing.T) {
t.Parallel() t.Parallel()
for _, port := range sshPorts { for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -342,7 +341,6 @@ func TestAgent_SessionExec(t *testing.T) {
t.Parallel() t.Parallel()
for _, port := range sshPorts { for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) { t.Run(fmt.Sprintf("(:%d)", port), func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -468,7 +466,6 @@ func TestAgent_SessionTTYShell(t *testing.T) {
} }
for _, port := range sshPorts { for _, port := range sshPorts {
port := port
t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) { t.Run(fmt.Sprintf("(%d)", port), func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -611,7 +608,6 @@ func TestAgent_Session_TTY_MOTD(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) { session := setupSSHSession(t, test.manifest, test.banner, func(fs afero.Fs) {
@@ -688,8 +684,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
//nolint:paralleltest // These tests need to swap the banner func. //nolint:paralleltest // These tests need to swap the banner func.
for _, port := range sshPorts { for _, port := range sshPorts {
port := port
sshClient, err := conn.SSHClientOnPort(ctx, port) sshClient, err := conn.SSHClientOnPort(ctx, port)
require.NoError(t, err) require.NoError(t, err)
t.Cleanup(func() { t.Cleanup(func() {
@@ -697,7 +691,6 @@ func TestAgent_Session_TTY_MOTD_Update(t *testing.T) {
}) })
for i, test := range tests { for i, test := range tests {
test := test
t.Run(fmt.Sprintf("(:%d)/%d", port, i), func(t *testing.T) { 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 // Set new banner func and wait for the agent to call it to update the
// banner. // banner.
@@ -1210,7 +1203,6 @@ func TestAgent_CoderEnvVars(t *testing.T) {
t.Parallel() t.Parallel()
for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_OWNER_NAME", "CODER_WORKSPACE_AGENT_NAME"} { for _, key := range []string{"CODER", "CODER_WORKSPACE_NAME", "CODER_WORKSPACE_OWNER_NAME", "CODER_WORKSPACE_AGENT_NAME"} {
key := key
t.Run(key, func(t *testing.T) { t.Run(key, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1233,7 +1225,6 @@ func TestAgent_SSHConnectionEnvVars(t *testing.T) {
// For some reason this test produces a TTY locally and a non-TTY in CI // 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. // so we don't test for the absence of SSH_TTY.
for _, key := range []string{"SSH_CONNECTION", "SSH_CLIENT"} { for _, key := range []string{"SSH_CONNECTION", "SSH_CLIENT"} {
key := key
t.Run(key, func(t *testing.T) { t.Run(key, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1276,7 +1267,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.key, func(t *testing.T) { t.Run(tt.key, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1796,7 +1786,6 @@ func TestAgent_ReconnectingPTY(t *testing.T) {
t.Setenv("LANG", "C") t.Setenv("LANG", "C")
for _, backendType := range backends { for _, backendType := range backends {
backendType := backendType
t.Run(backendType, func(t *testing.T) { t.Run(backendType, func(t *testing.T) {
if backendType == "Screen" { if backendType == "Screen" {
if runtime.GOOS != "linux" { if runtime.GOOS != "linux" {
@@ -2496,7 +2485,6 @@ func TestAgent_Dial(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -41,7 +41,6 @@ func TestWrapDockerExec(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt // appease the linter even though this isn't needed anymore
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actualCmd, actualArgs := wrapDockerExec("my-container", tt.containerUser, tt.cmdArgs[0], tt.cmdArgs[1:]...) 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) { func TestConvertDockerPort(t *testing.T) {
t.Parallel() t.Parallel()
//nolint:paralleltest // variable recapture no longer required
for _, tc := range []struct { for _, tc := range []struct {
name string name string
in string in string
@@ -101,7 +99,6 @@ func TestConvertDockerPort(t *testing.T) {
expectError: "invalid port", expectError: "invalid port",
}, },
} { } {
//nolint: paralleltest // variable recapture no longer required
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actualPort, actualNetwork, actualErr := convertDockerPort(tc.in) actualPort, actualNetwork, actualErr := convertDockerPort(tc.in)
@@ -151,7 +148,6 @@ func TestConvertDockerVolume(t *testing.T) {
expectError: "invalid volume", expectError: "invalid volume",
}, },
} { } {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
}) })
-1
View File
@@ -228,7 +228,6 @@ func Test_addXauthEntry(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -67,7 +67,6 @@ func TestLabelsEqual(t *testing.T) {
eq: false, eq: false,
}, },
} { } {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
require.Equal(t, tc.eq, proto.LabelsEqual(tc.a, tc.b)) require.Equal(t, tc.eq, proto.LabelsEqual(tc.a, tc.b))
@@ -65,8 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
queue := resourcesmonitor.NewQueue(20) queue := resourcesmonitor.NewQueue(20)
@@ -195,7 +195,6 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -72,7 +72,6 @@ func TestAPIVersionValidate(t *testing.T) {
expectedError: "no longer supported", expectedError: "no longer supported",
}, },
} { } {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -93,7 +93,6 @@ func TestBuildInfo(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2), require.Equal(t, c.expectMatch, buildinfo.VersionsMatch(c.v1, c.v2),
-1
View File
@@ -54,7 +54,6 @@ func Test_extractPort(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
got, err := extractPort(tt.urlString) got, err := extractPort(tt.urlString)
-1
View File
@@ -62,7 +62,6 @@ func TestAutoUpdate(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
client := coderdtest.New(t, nil) client := coderdtest.New(t, nil)
-1
View File
@@ -71,7 +71,6 @@ ExtractCommandPathsLoop:
} }
for _, tt := range cases { for _, tt := range cases {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
-3
View File
@@ -369,7 +369,6 @@ func TestAgent(t *testing.T) {
wantErr: true, wantErr: true,
}, },
} { } {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -648,7 +647,6 @@ func TestPeerDiagnostics(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
r, w := io.Pipe() r, w := io.Pipe()
@@ -852,7 +850,6 @@ func TestConnDiagnostics(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
r, w := io.Pipe() r, w := io.Pipe()
-2
View File
@@ -124,8 +124,6 @@ func TestProvisionerJob(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -40,7 +40,6 @@ func TestRenderAgentVersion(t *testing.T) {
}, },
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion) actual := renderAgentVersion(testCase.agentVersion, testCase.serverVersion)
-1
View File
@@ -169,7 +169,6 @@ foo <nil> 10 [a, b, c] foo1 11 foo2 12 fo
// Test with pointer values. // Test with pointer values.
inPtr := make([]*tableTest1, len(in)) inPtr := make([]*tableTest1, len(in))
for i, v := range in { for i, v := range in {
v := v
inPtr[i] = &v inPtr[i] = &v
} }
out, err = cliui.DisplayTable(inPtr, "", nil) out, err = cliui.DisplayTable(inPtr, "", nil)
@@ -95,7 +95,6 @@ func Test_Levenshtein_Matches(t *testing.T) {
Expected: []string{"kubernetes"}, Expected: []string{"kubernetes"},
}, },
} { } {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual := levenshtein.Matches(tt.Needle, tt.MaxDistance, tt.Haystack...) actual := levenshtein.Matches(tt.Needle, tt.MaxDistance, tt.Haystack...)
@@ -179,7 +178,6 @@ func Test_Levenshtein_Distance(t *testing.T) {
Error: levenshtein.ErrMaxDist.Error(), Error: levenshtein.ErrMaxDist.Error(),
}, },
} { } {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
actual, err := levenshtein.Distance(tt.A, tt.B, tt.MaxDist) actual, err := levenshtein.Distance(tt.A, tt.B, tt.MaxDist)
-1
View File
@@ -59,7 +59,6 @@ func TestWarnMatchedProvisioners(t *testing.T) {
}, },
}, },
} { } {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
var w strings.Builder var w strings.Builder
-5
View File
@@ -118,7 +118,6 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -157,7 +156,6 @@ func Test_sshConfigProxyCommandEscape(t *testing.T) {
} }
// nolint:paralleltest // Fixes a flake // nolint:paralleltest // Fixes a flake
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
if runtime.GOOS == "windows" { if runtime.GOOS == "windows" {
t.Skip("Windows doesn't typically execute via /bin/sh or cmd.exe, so this test is not applicable.") 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 // nolint:paralleltest // Fixes a flake
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
cmd := "/bin/sh" cmd := "/bin/sh"
arg := "-c" arg := "-c"
@@ -290,7 +287,6 @@ func Test_sshConfigExecEscapeSeparatorForce(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
found, err := sshConfigProxyCommandEscape(tt.path, tt.forceUnix) found, err := sshConfigProxyCommandEscape(tt.path, tt.forceUnix)
@@ -366,7 +362,6 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
} }
for _, tt := range testCases { for _, tt := range testCases {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -688,7 +688,6 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -49,7 +49,6 @@ ExtractCommandPathsLoop:
} }
for _, tt := range cases { for _, tt := range cases {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -60,7 +60,6 @@ func TestParse(t *testing.T) {
wantHost: "http://wow.io", wantHost: "http://wow.io",
}, },
} { } {
tc := tc
t.Run(tc.in, func(t *testing.T) { t.Run(tc.in, func(t *testing.T) {
t.Parallel() t.Parallel()
user, host, err := gitauth.ParseAskpass(tc.in) user, host, err := gitauth.ParseAskpass(tc.in)
-1
View File
@@ -48,7 +48,6 @@ func TestNotifications(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -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}, {"fail with no working directory and rel path on windows", args{relOrAbsPath: "my\\path", agentOS: "windows"}, "", true},
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() 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/", 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.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
baseURL, err := url.Parse(tt.baseURL) baseURL, err := url.Parse(tt.baseURL)
-6
View File
@@ -113,7 +113,6 @@ func TestOpenVSCode(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -240,7 +239,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -414,8 +412,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -579,8 +575,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -103,7 +103,6 @@ func Test_parsePortForwards(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -145,7 +145,6 @@ func TestPortForward(t *testing.T) {
) )
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name+"_OnePort", func(t *testing.T) { t.Run(c.name+"_OnePort", func(t *testing.T) {
t.Parallel() t.Parallel()
p1 := setupTestListener(t, c.setupRemote(t)) p1 := setupTestListener(t, c.setupRemote(t))
-1
View File
@@ -152,7 +152,6 @@ func TestProvisionerJobs(t *testing.T) {
{"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false}, {"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false},
{"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false}, {"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false},
} { } {
tt := tt
wantMsg := "OK" wantMsg := "OK"
if !tt.wantCancelled { if !tt.wantCancelled {
wantMsg = "FAIL" wantMsg = "FAIL"
-1
View File
@@ -76,7 +76,6 @@ func Test_formatExamples(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -100,7 +100,6 @@ func TestParseCLISchedule(t *testing.T) {
expectedError: errInvalidTimeFormat.Error(), expectedError: errInvalidTimeFormat.Error(),
}, },
} { } {
testCase := testCase
//nolint:paralleltest // t.Setenv //nolint:paralleltest // t.Setenv
t.Run(testCase.name, func(t *testing.T) { t.Run(testCase.name, func(t *testing.T) {
t.Setenv("TZ", testCase.tzEnv) t.Setenv("TZ", testCase.tzEnv)
-2
View File
@@ -341,8 +341,6 @@ func TestScheduleOverride(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.command, func(t *testing.T) { t.Run(tt.command, func(t *testing.T) {
// Given // Given
// Set timezone to Asia/Kolkata to surface any timezone-related bugs. // Set timezone to Asia/Kolkata to surface any timezone-related bugs.
-5
View File
@@ -62,7 +62,6 @@ func Test_configureCipherSuites(t *testing.T) {
cipherByName := func(cipher string) *tls.CipherSuite { cipherByName := func(cipher string) *tls.CipherSuite {
for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) { for _, c := range append(tls.CipherSuites(), tls.InsecureCipherSuites()...) {
if cipher == c.Name { if cipher == c.Name {
c := c
return c return c
} }
} }
@@ -173,7 +172,6 @@ func Test_configureCipherSuites(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := context.Background() ctx := context.Background()
@@ -245,7 +243,6 @@ func TestRedirectHTTPToHTTPSDeprecation(t *testing.T) {
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort) ctx := testutil.Context(t, testutil.WaitShort)
@@ -310,7 +307,6 @@ func TestIsDERPPath(t *testing.T) {
}, },
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.path, func(t *testing.T) { t.Run(tc.path, func(t *testing.T) {
t.Parallel() t.Parallel()
require.Equal(t, tc.expected, isDERPPath(tc.path)) require.Equal(t, tc.expected, isDERPPath(tc.path))
@@ -363,7 +359,6 @@ func TestEscapePostgresURLUserInfo(t *testing.T) {
}, },
} }
for _, tc := range testcases { for _, tc := range testcases {
tc := tc
t.Run(tc.input, func(t *testing.T) { t.Run(tc.input, func(t *testing.T) {
t.Parallel() t.Parallel()
o, err := escapePostgresURLUserInfo(tc.input) o, err := escapePostgresURLUserInfo(tc.input)
-4
View File
@@ -471,7 +471,6 @@ func TestServer(t *testing.T) {
expectGithubDefaultProviderConfigured: true, expectGithubDefaultProviderConfigured: true,
}, },
} { } {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
runGitHubProviderTest(t, tc) runGitHubProviderTest(t, tc)
}) })
@@ -629,7 +628,6 @@ func TestServer(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx, cancelFunc := context.WithCancel(context.Background()) ctx, cancelFunc := context.WithCancel(context.Background())
@@ -883,8 +881,6 @@ func TestServer(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -1517,7 +1517,6 @@ func TestSSH(t *testing.T) {
pty.ExpectMatchContext(ctx, "ping pong") pty.ExpectMatchContext(ctx, "ping pong")
for i, sock := range sockets { for i, sock := range sockets {
i := i
// Start the listener on the "local machine". // Start the listener on the "local machine".
l, err := net.Listen("unix", sock.local) l, err := net.Listen("unix", sock.local)
require.NoError(t, err) require.NoError(t, err)
@@ -1641,7 +1640,6 @@ func TestSSH(t *testing.T) {
} }
for _, tc := range tcs { for _, tc := range tcs {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -343,7 +343,6 @@ func TestStartAutoUpdate(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -299,7 +299,6 @@ func TestTemplateEdit(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -416,7 +415,6 @@ func TestTemplateEdit(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -262,8 +262,6 @@ func TestTemplatePull_ToDir(t *testing.T) {
// nolint: paralleltest // These tests change the current working dir, and is therefore unsuitable for parallelisation. // nolint: paralleltest // These tests change the current working dir, and is therefore unsuitable for parallelisation.
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
dir := t.TempDir() dir := t.TempDir()
-1
View File
@@ -485,7 +485,6 @@ func TestTemplatePush(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -30,7 +30,6 @@ func TestDurationDisplay(t *testing.T) {
{"24h1m1s", "1d"}, {"24h1m1s", "1d"},
{"25h", "1d1h"}, {"25h", "1d1h"},
} { } {
testCase := testCase
t.Run(testCase.Duration, func(t *testing.T) { t.Run(testCase.Duration, func(t *testing.T) {
t.Parallel() t.Parallel()
d, err := time.ParseDuration(testCase.Duration) d, err := time.ParseDuration(testCase.Duration)
@@ -71,7 +70,6 @@ func TestExtendedParseDuration(t *testing.T) {
{"200y200y200y200y200y", 0, false}, {"200y200y200y200y200y", 0, false},
{"9223372036854775807s", 0, false}, {"9223372036854775807s", 0, false},
} { } {
testCase := testCase
t.Run(testCase.Duration, func(t *testing.T) { t.Run(testCase.Duration, func(t *testing.T) {
t.Parallel() t.Parallel()
actual, err := extendedParseDuration(testCase.Duration) actual, err := extendedParseDuration(testCase.Duration)
-1
View File
@@ -50,7 +50,6 @@ Full build of Coder, supports the server subcommand.
Expected: expectedText, Expected: expectedText,
}, },
} { } {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
-1
View File
@@ -52,7 +52,6 @@ func TestVPNDaemonRun(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
@@ -80,7 +80,6 @@ func Test_vscodeProxyURI(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -280,8 +280,6 @@ func TestMemoryResourceMonitor(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -713,8 +711,6 @@ func TestVolumeResourceMonitor(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -43,8 +43,6 @@ func TestValidateAggregationLabels(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -107,7 +107,6 @@ func TestGenerate(t *testing.T) {
} }
for _, tc := range cases { for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -454,7 +454,6 @@ func TestAuditLogsFilter(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
// Test filtering // Test filtering
t.Run(testCase.Name, func(t *testing.T) { t.Run(testCase.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -125,8 +125,6 @@ func TestCheckPermissions(t *testing.T) {
} }
for _, c := range testCases { for _, c := range testCases {
c := c
t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) { t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -153,7 +153,6 @@ func Test_isEligibleForAutostart(t *testing.T) {
} }
for _, c := range testCases { for _, c := range testCases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -177,7 +177,6 @@ func TestExecutorAutostartTemplateUpdated(t *testing.T) {
}, },
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
var ( var (
-1
View File
@@ -83,7 +83,6 @@ func TestNotifier(t *testing.T) {
} }
for _, testCase := range testCases { for _, testCase := range testCases {
testCase := testCase
t.Run(testCase.Name, func(t *testing.T) { t.Run(testCase.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort) ctx := testutil.Context(t, testutil.WaitShort)
@@ -47,7 +47,6 @@ func TestValidate(t *testing.T) {
vmID: "960a4b4a-dab2-44ef-9b73-7753043b4f16", vmID: "960a4b4a-dab2-44ef-9b73-7753043b4f16",
date: mustTime(time.RFC3339, "2024-04-22T17:32:44Z"), date: mustTime(time.RFC3339, "2024-04-22T17:32:44Z"),
}} { }} {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
vm, err := azureidentity.Validate(context.Background(), tc.payload, azureidentity.Options{ vm, err := azureidentity.Validate(context.Background(), tc.payload, azureidentity.Options{
-2
View File
@@ -32,8 +32,6 @@ func TestStripSlashesMW(t *testing.T) {
}) })
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run("chi/"+tt.name, func(t *testing.T) { t.Run("chi/"+tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
req := httptest.NewRequest("GET", tt.inputPath, nil) req := httptest.NewRequest("GET", tt.inputPath, nil)
-2
View File
@@ -119,8 +119,6 @@ func TestProvisionerJobStatus(t *testing.T) {
org := dbgen.Organization(t, db, database.Organization{}) org := dbgen.Organization(t, db, database.Organization{})
for i, tc := range cases { for i, tc := range cases {
tc := tc
i := i
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
// Populate standard fields // Populate standard fields
@@ -46,7 +46,6 @@ func TestInsertCustomRoles(t *testing.T) {
merge := func(u ...interface{}) rbac.Roles { merge := func(u ...interface{}) rbac.Roles {
all := make([]rbac.Role, 0) all := make([]rbac.Role, 0)
for _, v := range u { for _, v := range u {
v := v
switch t := v.(type) { switch t := v.(type) {
case rbac.Role: case rbac.Role:
all = append(all, t) all = append(all, t)
@@ -201,8 +200,6 @@ func TestInsertCustomRoles(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
db := dbmem.New() db := dbmem.New()
@@ -135,7 +135,6 @@ func TestGroupsAuth(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -458,7 +458,6 @@ type AssertRBAC struct {
func values(ins ...any) []reflect.Value { func values(ins ...any) []reflect.Value {
out := make([]reflect.Value, 0) out := make([]reflect.Value, 0)
for _, input := range ins { for _, input := range ins {
input := input
out = append(out, reflect.ValueOf(input)) out = append(out, reflect.ValueOf(input))
} }
return out return out
-5
View File
@@ -1811,7 +1811,6 @@ func (q *FakeQuerier) CustomRoles(_ context.Context, arg database.CustomRolesPar
found := make([]database.CustomRole, 0) found := make([]database.CustomRole, 0)
for _, role := range q.data.customRoles { for _, role := range q.data.customRoles {
role := role
if len(arg.LookupRoles) > 0 { if len(arg.LookupRoles) > 0 {
if !slices.ContainsFunc(arg.LookupRoles, func(pair database.NameOrganizationPair) bool { if !slices.ContainsFunc(arg.LookupRoles, func(pair database.NameOrganizationPair) bool {
if pair.Name != role.Name { if pair.Name != role.Name {
@@ -2920,7 +2919,6 @@ func (q *FakeQuerier) GetAuthorizationUserRoles(_ context.Context, userID uuid.U
roles := make([]string, 0) roles := make([]string, 0)
for _, u := range q.users { for _, u := range q.users {
if u.ID == userID { if u.ID == userID {
u := u
roles = append(roles, u.RBACRoles...) roles = append(roles, u.RBACRoles...)
roles = append(roles, "member") roles = append(roles, "member")
user = &u user = &u
@@ -8123,7 +8121,6 @@ func (q *FakeQuerier) GetWorkspaceByOwnerIDAndName(_ context.Context, arg databa
var found *database.WorkspaceTable var found *database.WorkspaceTable
for _, workspace := range q.workspaces { for _, workspace := range q.workspaces {
workspace := workspace
if workspace.OwnerID != arg.OwnerID { if workspace.OwnerID != arg.OwnerID {
continue continue
} }
@@ -8181,7 +8178,6 @@ func (q *FakeQuerier) GetWorkspaceByWorkspaceAppID(_ context.Context, workspaceA
defer q.mutex.RUnlock() defer q.mutex.RUnlock()
for _, workspaceApp := range q.workspaceApps { for _, workspaceApp := range q.workspaceApps {
workspaceApp := workspaceApp
if workspaceApp.ID == workspaceAppID { if workspaceApp.ID == workspaceAppID {
return q.getWorkspaceByAgentIDNoLock(context.Background(), workspaceApp.AgentID) return q.getWorkspaceByAgentIDNoLock(context.Background(), workspaceApp.AgentID)
} }
@@ -10424,7 +10420,6 @@ func (q *FakeQuerier) OrganizationMembers(_ context.Context, arg database.Organi
continue continue
} }
organizationMember := organizationMember
user, _ := q.getUserByIDNoLock(organizationMember.UserID) user, _ := q.getUserByIDNoLock(organizationMember.UserID)
tmp = append(tmp, database.OrganizationMembersRow{ tmp = append(tmp, database.OrganizationMembersRow{
OrganizationMember: organizationMember, OrganizationMember: organizationMember,
-1
View File
@@ -188,7 +188,6 @@ func TestProxyByHostname(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -288,8 +288,6 @@ func TestMigrateUpWithFixtures(t *testing.T) {
}) })
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-9
View File
@@ -1156,7 +1156,6 @@ func TestProxyByHostname(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1394,7 +1393,6 @@ func TestGetUsers_IncludeSystem(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1862,8 +1860,6 @@ func TestReadCustomRoles(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2506,7 +2502,6 @@ func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc // Capture loop variable to avoid data races
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
db, _ := dbtestutil.NewDB(t) db, _ := dbtestutil.NewDB(t)
@@ -2947,7 +2942,6 @@ func TestGetUserStatusCounts(t *testing.T) {
} }
for _, tz := range timezones { for _, tz := range timezones {
tz := tz
t.Run(tz, func(t *testing.T) { t.Run(tz, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2995,7 +2989,6 @@ func TestGetUserStatusCounts(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
db, _ := dbtestutil.NewDB(t) db, _ := dbtestutil.NewDB(t)
@@ -3163,7 +3156,6 @@ func TestGetUserStatusCounts(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
db, _ := dbtestutil.NewDB(t) db, _ := dbtestutil.NewDB(t)
@@ -3296,7 +3288,6 @@ func TestGetUserStatusCounts(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -48,8 +48,6 @@ func TestTunnel(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -102,7 +102,6 @@ func TestGitlabDefaults(t *testing.T) {
}, },
} }
for _, c := range tests { for _, c := range tests {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
applyDefaultsToConfig(&c.input) applyDefaultsToConfig(&c.input)
@@ -177,7 +176,6 @@ func Test_bitbucketServerConfigDefaults(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
applyDefaultsToConfig(tt.config) applyDefaultsToConfig(tt.config)
-1
View File
@@ -463,7 +463,6 @@ func TestConvertYAML(t *testing.T) {
}}, }},
Error: "device auth url must be provided", Error: "device auth url must be provided",
}} { }} {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
output, err := externalauth.ConvertConfig(instrument, tc.Input, &url.URL{}) output, err := externalauth.ConvertConfig(instrument, tc.Input, &url.URL{})
-1
View File
@@ -21,7 +21,6 @@ func Test_MessageURL(t *testing.T) {
{"default", health.CodeAccessURLFetch, "", "https://coder.com/docs/admin/monitoring/health-check#eacs03"}, {"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"}, {"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.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
uut := health.Message{Code: tt.code} uut := health.Message{Code: tt.code}
-1
View File
@@ -508,7 +508,6 @@ func TestHealthcheck(t *testing.T) {
}, },
severity: health.SeverityError, severity: health.SeverityError,
}} { }} {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -335,7 +335,6 @@ func TestProvisionerDaemonReport(t *testing.T) {
expectedItems: []healthsdk.ProvisionerDaemonsReportItem{}, expectedItems: []healthsdk.ProvisionerDaemonsReportItem{},
}, },
} { } {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -47,7 +47,6 @@ func Test_WorkspaceProxyReport_appendErrors(t *testing.T) {
errs: []string{assert.AnError.Error(), "another error"}, errs: []string{assert.AnError.Error(), "another error"},
}, },
} { } {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -85,7 +84,6 @@ func Test_calculateSeverity(t *testing.T) {
{2, 0, 0, health.SeverityError}, {2, 0, 0, health.SeverityError},
{2, 0, 1, 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) 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.Run(name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -172,7 +172,6 @@ func TestWorkspaceProxies(t *testing.T) {
expectedSeverity: health.SeverityError, expectedSeverity: health.SeverityError,
}, },
} { } {
tt := tt
if tt.name != "Enabled/ProxyWarnings" { if tt.name != "Enabled/ProxyWarnings" {
continue continue
} }
-1
View File
@@ -26,7 +26,6 @@ func TestStripCoderCookies(t *testing.T) {
"coder_session_token=ok; oauth_state=wow; oauth_redirect=/", "coder_session_token=ok; oauth_state=wow; oauth_redirect=/",
"", "",
}} { }} {
tc := tc
t.Run(tc.Input, func(t *testing.T) { t.Run(tc.Input, func(t *testing.T) {
t.Parallel() t.Parallel()
require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input)) require.Equal(t, tc.Output, httpapi.StripCoderCookies(tc.Input))
-6
View File
@@ -46,8 +46,6 @@ func TestDuration(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.expected, func(t *testing.T) { t.Run(c.expected, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -109,8 +107,6 @@ func TestDuration(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.value, func(t *testing.T) { t.Run(c.value, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -153,8 +149,6 @@ func TestDuration(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.value, func(t *testing.T) { t.Run(c.value, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -107,7 +107,6 @@ func TestExtractUserRoles(t *testing.T) {
} }
for _, c := range testCases { for _, c := range testCases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -91,7 +91,6 @@ func TestWorkspaceAppCors(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -57,7 +57,6 @@ func TestCSRFExemptList(t *testing.T) {
csrfmw := mw(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})).(*nosurf.CSRFHandler) csrfmw := mw(http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {})).(*nosurf.CSRFHandler)
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -77,7 +77,6 @@ func TestHSTS(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -247,7 +247,6 @@ func TestRequestLogger_RouteParamsLogging(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -108,7 +108,6 @@ func Test_RoutePatterns(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-10
View File
@@ -200,7 +200,6 @@ func TestExtractAddress(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -235,9 +234,6 @@ func TestTrustedOrigins(t *testing.T) {
// ipv6: trust an IPv4 network // ipv6: trust an IPv4 network
for _, trusted := range []string{"none", "ipv4", "ipv6"} { for _, trusted := range []string{"none", "ipv4", "ipv6"} {
for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { 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)) name := fmt.Sprintf("%s-%s-%s", trusted, proto, strings.ToLower(header))
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
@@ -311,7 +307,6 @@ func TestCorruptedHeaders(t *testing.T) {
t.Parallel() t.Parallel()
for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} { for _, header := range []string{"Cf-Connecting-Ip", "True-Client-Ip", "X-Real-Ip", "X-Forwarded-For"} {
header := header
name := strings.ToLower(header) name := strings.ToLower(header)
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
@@ -364,9 +359,6 @@ func TestAddressFamilies(t *testing.T) {
for _, clientFamily := range []string{"ipv4", "ipv6"} { for _, clientFamily := range []string{"ipv4", "ipv6"} {
for _, proxyFamily := 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"} { 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) name := fmt.Sprintf("%s-%s-%s", strings.ToLower(header), clientFamily, proxyFamily)
t.Run(name, func(t *testing.T) { t.Run(name, func(t *testing.T) {
@@ -466,7 +458,6 @@ func TestFilterUntrusted(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -612,7 +603,6 @@ func TestApplicationProxy(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.Name, func(t *testing.T) { t.Run(test.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -52,8 +52,6 @@ func TestRecover(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -316,7 +316,6 @@ func TestWorkspaceAgentByNameParam(t *testing.T) {
} }
for _, c := range testCases { for _, c := range testCases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
db, r := setupWorkspaceWithAgents(t, setupConfig{ db, r := setupWorkspaceWithAgents(t, setupConfig{
-5
View File
@@ -243,7 +243,6 @@ func TestGroupSyncTable(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
// The final test, "AllTogether", cannot run in parallel. // The final test, "AllTogether", cannot run in parallel.
// These tests are nearly instant using the memory db, so // These tests are nearly instant using the memory db, so
// this is still fast without being in parallel. // this is still fast without being in parallel.
@@ -341,8 +340,6 @@ func TestGroupSyncTable(t *testing.T) {
}) })
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
orgID := uuid.New() orgID := uuid.New()
SetupOrganization(t, s, db, user, orgID, tc) SetupOrganization(t, s, db, user, orgID, tc)
asserts = append(asserts, func(t *testing.T) { asserts = append(asserts, func(t *testing.T) {
@@ -523,7 +520,6 @@ func TestApplyGroupDifference(t *testing.T) {
} }
for _, tc := range testCase { for _, tc := range testCase {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -713,7 +709,6 @@ func TestExpectedGroupEqual(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -159,7 +159,6 @@ func TestParseStringSliceClaim(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
-3
View File
@@ -186,7 +186,6 @@ func TestRoleSyncTable(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
// The final test, "AllTogether", cannot run in parallel. // The final test, "AllTogether", cannot run in parallel.
// These tests are nearly instant using the memory db, so // These tests are nearly instant using the memory db, so
// this is still fast without being in parallel. // this is still fast without being in parallel.
@@ -248,8 +247,6 @@ func TestRoleSyncTable(t *testing.T) {
var asserts []func(t *testing.T) var asserts []func(t *testing.T)
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
orgID := uuid.New() orgID := uuid.New()
SetupOrganization(t, s, db, user, orgID, tc) SetupOrganization(t, s, db, user, orgID, tc)
asserts = append(asserts, func(t *testing.T) { asserts = append(asserts, func(t *testing.T) {
@@ -29,8 +29,6 @@ func TestInboxNotifications_ensureNotificationIcon(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -57,7 +57,6 @@ func TestInboxNotification_Watch(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -393,7 +392,6 @@ func TestInboxNotifications_List(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-4
View File
@@ -144,7 +144,6 @@ func Test_parseInsightsStartAndEndTime(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -253,8 +252,6 @@ func Test_parseInsightsInterval_week(t *testing.T) {
}, },
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -323,7 +320,6 @@ func TestLastReportIntervalHasAtLeastSixDays(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-21
View File
@@ -550,8 +550,6 @@ func TestTemplateInsights_Golden(t *testing.T) {
// Prepare all the templates. // Prepare all the templates.
for _, template := range templates { for _, template := range templates {
template := template
var parameters []*proto.RichParameter var parameters []*proto.RichParameter
for _, parameter := range template.parameters { for _, parameter := range template.parameters {
var options []*proto.RichParameterOption var options []*proto.RichParameterOption
@@ -582,10 +580,7 @@ func TestTemplateInsights_Golden(t *testing.T) {
) )
var resources []*proto.Resource var resources []*proto.Resource
for _, user := range users { for _, user := range users {
user := user
for _, workspace := range user.workspaces { for _, workspace := range user.workspaces {
workspace := workspace
if workspace.template != template { if workspace.template != template {
continue continue
} }
@@ -1246,7 +1241,6 @@ func TestTemplateInsights_Golden(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1261,7 +1255,6 @@ func TestTemplateInsights_Golden(t *testing.T) {
_, _ = <-events, <-events _, _ = <-events, <-events
for _, req := range tt.requests { for _, req := range tt.requests {
req := req
t.Run(req.name, func(t *testing.T) { t.Run(req.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1489,8 +1482,6 @@ func TestUserActivityInsights_Golden(t *testing.T) {
// Prepare all the templates. // Prepare all the templates.
for _, template := range templates { for _, template := range templates {
template := template
// Prepare all workspace resources (agents and apps). // Prepare all workspace resources (agents and apps).
var ( var (
createWorkspaces []func(uuid.UUID) createWorkspaces []func(uuid.UUID)
@@ -1498,10 +1489,7 @@ func TestUserActivityInsights_Golden(t *testing.T) {
) )
var resources []*proto.Resource var resources []*proto.Resource
for _, user := range users { for _, user := range users {
user := user
for _, workspace := range user.workspaces { for _, workspace := range user.workspaces {
workspace := workspace
if workspace.template != template { if workspace.template != template {
continue continue
} }
@@ -2031,7 +2019,6 @@ func TestUserActivityInsights_Golden(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2046,7 +2033,6 @@ func TestUserActivityInsights_Golden(t *testing.T) {
_, _ = <-events, <-events _, _ = <-events, <-events
for _, req := range tt.requests { for _, req := range tt.requests {
req := req
t.Run(req.name, func(t *testing.T) { t.Run(req.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2159,8 +2145,6 @@ func TestTemplateInsights_RBAC(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) { t.Run(fmt.Sprintf("with interval=%q", tt.interval), func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2279,9 +2263,6 @@ func TestGenericInsights_RBAC(t *testing.T) {
} }
for endpointName, endpoint := range endpoints { for endpointName, endpoint := range endpoints {
endpointName := endpointName
endpoint := endpoint
t.Run(fmt.Sprintf("With%sEndpoint", endpointName), func(t *testing.T) { t.Run(fmt.Sprintf("With%sEndpoint", endpointName), func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2291,8 +2272,6 @@ func TestGenericInsights_RBAC(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run("AsOwner", func(t *testing.T) { t.Run("AsOwner", func(t *testing.T) {
t.Parallel() t.Parallel()
-2
View File
@@ -844,8 +844,6 @@ func TestDetectorPushesLogs(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-3
View File
@@ -149,12 +149,9 @@ func TestClaims(t *testing.T) {
} }
for _, tt := range types { for _, tt := range types {
tt := tt
t.Run(tt.Name, func(t *testing.T) { t.Run(tt.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.name, func(t *testing.T) { t.Run(c.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -202,7 +202,6 @@ func TestCache_BuildTime(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -69,7 +69,6 @@ func TestInbox(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -1283,8 +1283,6 @@ func TestNotificationTemplates_Golden(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -2006,8 +2004,6 @@ func TestNotificationTargetMatrix(t *testing.T) {
} }
for _, tt := range tests { for _, tt := range tests {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -68,8 +68,6 @@ func TestGoTemplate(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc // unnecessary as of go1.22 but the linter is outdated
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-4
View File
@@ -151,7 +151,6 @@ func TestOAuth2ProviderApps(t *testing.T) {
require.NoError(t, err) require.NoError(t, err)
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
@@ -661,7 +660,6 @@ func TestOAuth2ProviderTokenExchange(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
@@ -804,7 +802,6 @@ func TestOAuth2ProviderTokenRefresh(t *testing.T) {
}, },
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
@@ -996,7 +993,6 @@ func TestOAuth2ProviderRevoke(t *testing.T) {
} }
for _, test := range tests { for _, test := range tests {
test := test
t.Run(test.name, func(t *testing.T) { t.Run(test.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitLong) ctx := testutil.Context(t, testutil.WaitLong)
-1
View File
@@ -110,7 +110,6 @@ func TestPagination(t *testing.T) {
} }
for _, c := range testCases { for _, c := range testCases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
rw := httptest.NewRecorder() rw := httptest.NewRecorder()
-2
View File
@@ -420,7 +420,6 @@ func TestInProgressActions(t *testing.T) {
} }
for _, tc := range cases { for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -650,7 +649,6 @@ func TestExpiredPrebuilds(t *testing.T) {
} }
for _, tc := range cases { for _, tc := range cases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
-1
View File
@@ -78,7 +78,6 @@ func TestTemplateVersionPresets(t *testing.T) {
} }
for _, tc := range testCases { for _, tc := range testCases {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort) ctx := testutil.Context(t, testutil.WaitShort)
@@ -587,8 +587,6 @@ func TestLabelsAggregation(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -29,8 +29,6 @@ func TestFilterAcceptableAgentLabels(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -99,7 +99,6 @@ func TestActiveUsers(t *testing.T) {
}, },
Count: 2, Count: 2,
}} { }} {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
registry := prometheus.NewRegistry() registry := prometheus.NewRegistry()
@@ -161,7 +160,6 @@ func TestUsers(t *testing.T) {
}, },
Count: map[database.UserStatus]int{database.UserStatusActive: 3}, Count: map[database.UserStatus]int{database.UserStatusActive: 3},
}} { }} {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort) ctx, cancel := context.WithTimeout(context.Background(), testutil.WaitShort)
@@ -250,7 +248,6 @@ func TestWorkspaceLatestBuildTotals(t *testing.T) {
codersdk.ProvisionerJobRunning: 1, codersdk.ProvisionerJobRunning: 1,
}, },
}} { }} {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
registry := prometheus.NewRegistry() registry := prometheus.NewRegistry()
@@ -327,7 +324,6 @@ func TestWorkspaceLatestBuildStatuses(t *testing.T) {
codersdk.ProvisionerJobRunning: 1, codersdk.ProvisionerJobRunning: 1,
}, },
}} { }} {
tc := tc
t.Run(tc.Name, func(t *testing.T) { t.Run(tc.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
registry := prometheus.NewRegistry() registry := prometheus.NewRegistry()
@@ -660,8 +656,6 @@ func TestExperimentsMetric(t *testing.T) {
} }
for _, tc := range tests { for _, tc := range tests {
tc := tc
t.Run(tc.name, func(t *testing.T) { t.Run(tc.name, func(t *testing.T) {
t.Parallel() t.Parallel()
reg := prometheus.NewRegistry() reg := prometheus.NewRegistry()
-1
View File
@@ -155,7 +155,6 @@ func TestGithubRateLimits(t *testing.T) {
} }
for _, c := range cases { for _, c := range cases {
c := c
t.Run(c.Name, func(t *testing.T) { t.Run(c.Name, func(t *testing.T) {
t.Parallel() t.Parallel()
@@ -466,7 +466,6 @@ func TestAcquirer_MatchTags(t *testing.T) {
}, },
} }
for _, tt := range testCases { for _, tt := range testCases {
tt := tt
t.Run(tt.name, func(t *testing.T) { t.Run(tt.name, func(t *testing.T) {
t.Parallel() t.Parallel()
ctx := testutil.Context(t, testutil.WaitShort) ctx := testutil.Context(t, testutil.WaitShort)

Some files were not shown because too many files have changed in this diff Show More