mirror of
https://github.com/coder/coder.git
synced 2026-06-02 20:48:20 +00:00
chore: remove unnecessary redeclarations in for loops (#18440)
This commit is contained in:
@@ -130,7 +130,6 @@ 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 +341,6 @@ 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 +466,6 @@ 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 +608,6 @@ 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,8 +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 {
|
||||
port := port
|
||||
|
||||
sshClient, err := conn.SSHClientOnPort(ctx, port)
|
||||
require.NoError(t, err)
|
||||
t.Cleanup(func() {
|
||||
@@ -697,7 +691,6 @@ 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 +1203,6 @@ func TestAgent_CoderEnvVars(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
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.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
|
||||
// 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 +1267,6 @@ func TestAgent_SSHConnectionLoginVars(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.key, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1796,7 +1786,6 @@ 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 +2485,6 @@ func TestAgent_Dial(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -41,7 +41,6 @@ func TestWrapDockerExec(t *testing.T) {
|
||||
},
|
||||
}
|
||||
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.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",
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
})
|
||||
|
||||
@@ -228,7 +228,6 @@ 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()
|
||||
|
||||
|
||||
@@ -67,7 +67,6 @@ 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))
|
||||
|
||||
@@ -65,8 +65,6 @@ func TestResourceMonitorQueue(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
queue := resourcesmonitor.NewQueue(20)
|
||||
|
||||
@@ -195,7 +195,6 @@ func TestPushResourcesMonitoringWithConfig(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -72,7 +72,6 @@ func TestAPIVersionValidate(t *testing.T) {
|
||||
expectedError: "no longer supported",
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -93,7 +93,6 @@ 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),
|
||||
|
||||
@@ -54,7 +54,6 @@ 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)
|
||||
|
||||
@@ -62,7 +62,6 @@ 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)
|
||||
|
||||
@@ -71,7 +71,6 @@ ExtractCommandPathsLoop:
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
tt := tt
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitLong)
|
||||
|
||||
@@ -369,7 +369,6 @@ func TestAgent(t *testing.T) {
|
||||
wantErr: true,
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -648,7 +647,6 @@ 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 +850,6 @@ 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()
|
||||
|
||||
@@ -124,8 +124,6 @@ func TestProvisionerJob(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -40,7 +40,6 @@ 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)
|
||||
|
||||
@@ -169,7 +169,6 @@ foo <nil> 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)
|
||||
|
||||
@@ -95,7 +95,6 @@ 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 +178,6 @@ 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)
|
||||
|
||||
@@ -59,7 +59,6 @@ func TestWarnMatchedProvisioners(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var w strings.Builder
|
||||
|
||||
@@ -118,7 +118,6 @@ func Test_sshConfigSplitOnCoderSection(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
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 {
|
||||
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 +205,6 @@ 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 +287,6 @@ 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 +362,6 @@ func Test_sshConfigOptions_addOption(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range testCases {
|
||||
tt := tt
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -688,7 +688,6 @@ func TestConfigSSH_FileWriteAndOptionsFlow(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -49,7 +49,6 @@ ExtractCommandPathsLoop:
|
||||
}
|
||||
|
||||
for _, tt := range cases {
|
||||
tt := tt
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -60,7 +60,6 @@ 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)
|
||||
|
||||
@@ -48,7 +48,6 @@ func TestNotifications(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -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 {
|
||||
tt := tt
|
||||
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/",
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
baseURL, err := url.Parse(tt.baseURL)
|
||||
|
||||
@@ -113,7 +113,6 @@ func TestOpenVSCode(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -240,7 +239,6 @@ func TestOpenVSCode_NoAgentDirectory(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -414,8 +412,6 @@ func TestOpenVSCodeDevContainer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -579,8 +575,6 @@ func TestOpenVSCodeDevContainer_NoAgentDirectory(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -103,7 +103,6 @@ func Test_parsePortForwards(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -145,7 +145,6 @@ 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))
|
||||
|
||||
@@ -152,7 +152,6 @@ func TestProvisionerJobs(t *testing.T) {
|
||||
{"Member", memberClient, "TemplateVersionImport", prepareTemplateVersionImportJob, false},
|
||||
{"Member", memberClient, "TemplateVersionImportDryRun", prepareTemplateVersionImportJobDryRun, false},
|
||||
} {
|
||||
tt := tt
|
||||
wantMsg := "OK"
|
||||
if !tt.wantCancelled {
|
||||
wantMsg = "FAIL"
|
||||
|
||||
@@ -76,7 +76,6 @@ func Test_formatExamples(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -100,7 +100,6 @@ 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)
|
||||
|
||||
@@ -341,8 +341,6 @@ func TestScheduleOverride(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.command, func(t *testing.T) {
|
||||
// Given
|
||||
// Set timezone to Asia/Kolkata to surface any timezone-related bugs.
|
||||
|
||||
@@ -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 {
|
||||
c := c
|
||||
return c
|
||||
}
|
||||
}
|
||||
@@ -173,7 +172,6 @@ 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 +243,6 @@ 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 +307,6 @@ 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 +359,6 @@ 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)
|
||||
|
||||
@@ -471,7 +471,6 @@ func TestServer(t *testing.T) {
|
||||
expectGithubDefaultProviderConfigured: true,
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
runGitHubProviderTest(t, tc)
|
||||
})
|
||||
@@ -629,7 +628,6 @@ 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,8 +881,6 @@ func TestServer(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -1517,7 +1517,6 @@ 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 +1640,6 @@ func TestSSH(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tcs {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -343,7 +343,6 @@ func TestStartAutoUpdate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -299,7 +299,6 @@ func TestTemplateEdit(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -416,7 +415,6 @@ func TestTemplateEdit(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -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.
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
dir := t.TempDir()
|
||||
|
||||
|
||||
@@ -485,7 +485,6 @@ func TestTemplatePush(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ 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 +70,6 @@ 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)
|
||||
|
||||
@@ -50,7 +50,6 @@ 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)
|
||||
|
||||
@@ -52,7 +52,6 @@ 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)
|
||||
|
||||
@@ -80,7 +80,6 @@ func Test_vscodeProxyURI(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -280,8 +280,6 @@ func TestMemoryResourceMonitor(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -713,8 +711,6 @@ func TestVolumeResourceMonitor(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -43,8 +43,6 @@ func TestValidateAggregationLabels(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -107,7 +107,6 @@ func TestGenerate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -454,7 +454,6 @@ func TestAuditLogsFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
// Test filtering
|
||||
t.Run(testCase.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -125,8 +125,6 @@ func TestCheckPermissions(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
|
||||
t.Run("CheckAuthorization/"+c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -153,7 +153,6 @@ func Test_isEligibleForAutostart(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -177,7 +177,6 @@ func TestExecutorAutostartTemplateUpdated(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
|
||||
@@ -83,7 +83,6 @@ 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)
|
||||
|
||||
@@ -47,7 +47,6 @@ 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{
|
||||
|
||||
@@ -32,8 +32,6 @@ func TestStripSlashesMW(t *testing.T) {
|
||||
})
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run("chi/"+tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
req := httptest.NewRequest("GET", tt.inputPath, nil)
|
||||
|
||||
@@ -119,8 +119,6 @@ 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
|
||||
|
||||
@@ -46,7 +46,6 @@ 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,8 +200,6 @@ func TestInsertCustomRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db := dbmem.New()
|
||||
|
||||
@@ -135,7 +135,6 @@ func TestGroupsAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -458,7 +458,6 @@ 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
|
||||
|
||||
@@ -1811,7 +1811,6 @@ 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 {
|
||||
@@ -2920,7 +2919,6 @@ 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
|
||||
@@ -8123,7 +8121,6 @@ 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
|
||||
}
|
||||
@@ -8181,7 +8178,6 @@ 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)
|
||||
}
|
||||
@@ -10424,7 +10420,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,
|
||||
|
||||
@@ -188,7 +188,6 @@ func TestProxyByHostname(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -288,8 +288,6 @@ func TestMigrateUpWithFixtures(t *testing.T) {
|
||||
})
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -1156,7 +1156,6 @@ func TestProxyByHostname(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1394,7 +1393,6 @@ func TestGetUsers_IncludeSystem(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1862,8 +1860,6 @@ func TestReadCustomRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2506,7 +2502,6 @@ func TestGetProvisionerJobsByIDsWithQueuePosition(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc // Capture loop variable to avoid data races
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
db, _ := dbtestutil.NewDB(t)
|
||||
@@ -2947,7 +2942,6 @@ func TestGetUserStatusCounts(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tz := range timezones {
|
||||
tz := tz
|
||||
t.Run(tz, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2995,7 +2989,6 @@ 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)
|
||||
@@ -3163,7 +3156,6 @@ 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)
|
||||
@@ -3296,7 +3288,6 @@ func TestGetUserStatusCounts(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -48,8 +48,6 @@ func TestTunnel(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -102,7 +102,6 @@ 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 +176,6 @@ 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)
|
||||
|
||||
@@ -463,7 +463,6 @@ 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{})
|
||||
|
||||
@@ -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"},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
uut := health.Message{Code: tt.code}
|
||||
|
||||
@@ -508,7 +508,6 @@ func TestHealthcheck(t *testing.T) {
|
||||
},
|
||||
severity: health.SeverityError,
|
||||
}} {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -335,7 +335,6 @@ func TestProvisionerDaemonReport(t *testing.T) {
|
||||
expectedItems: []healthsdk.ProvisionerDaemonsReportItem{},
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -47,7 +47,6 @@ 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 +84,6 @@ 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()
|
||||
|
||||
@@ -172,7 +172,6 @@ func TestWorkspaceProxies(t *testing.T) {
|
||||
expectedSeverity: health.SeverityError,
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
if tt.name != "Enabled/ProxyWarnings" {
|
||||
continue
|
||||
}
|
||||
|
||||
@@ -26,7 +26,6 @@ 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))
|
||||
|
||||
@@ -46,8 +46,6 @@ func TestDuration(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.expected, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -109,8 +107,6 @@ func TestDuration(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.value, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -153,8 +149,6 @@ func TestDuration(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.value, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -107,7 +107,6 @@ func TestExtractUserRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -91,7 +91,6 @@ func TestWorkspaceAppCors(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -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 {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -77,7 +77,6 @@ func TestHSTS(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -247,7 +247,6 @@ func TestRequestLogger_RouteParamsLogging(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -108,7 +108,6 @@ func Test_RoutePatterns(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -200,7 +200,6 @@ func TestExtractAddress(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -235,9 +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"} {
|
||||
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 +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"} {
|
||||
header := header
|
||||
name := strings.ToLower(header)
|
||||
|
||||
t.Run(name, func(t *testing.T) {
|
||||
@@ -364,9 +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"} {
|
||||
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 +458,6 @@ func TestFilterUntrusted(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -612,7 +603,6 @@ func TestApplicationProxy(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, test := range tests {
|
||||
test := test
|
||||
t.Run(test.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -52,8 +52,6 @@ func TestRecover(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -316,7 +316,6 @@ 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{
|
||||
|
||||
@@ -243,7 +243,6 @@ 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,8 +340,6 @@ func TestGroupSyncTable(t *testing.T) {
|
||||
})
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
|
||||
orgID := uuid.New()
|
||||
SetupOrganization(t, s, db, user, orgID, tc)
|
||||
asserts = append(asserts, func(t *testing.T) {
|
||||
@@ -523,7 +520,6 @@ func TestApplyGroupDifference(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCase {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -713,7 +709,6 @@ func TestExpectedGroupEqual(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -159,7 +159,6 @@ func TestParseStringSliceClaim(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -186,7 +186,6 @@ 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,8 +247,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)
|
||||
asserts = append(asserts, func(t *testing.T) {
|
||||
|
||||
@@ -29,8 +29,6 @@ func TestInboxNotifications_ensureNotificationIcon(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ func TestInboxNotification_Watch(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -393,7 +392,6 @@ func TestInboxNotifications_List(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -144,7 +144,6 @@ func Test_parseInsightsStartAndEndTime(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -253,8 +252,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 +320,6 @@ func TestLastReportIntervalHasAtLeastSixDays(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -550,8 +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 {
|
||||
var options []*proto.RichParameterOption
|
||||
@@ -582,10 +580,7 @@ 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 +1241,6 @@ func TestTemplateInsights_Golden(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1261,7 +1255,6 @@ 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,8 +1482,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 (
|
||||
createWorkspaces []func(uuid.UUID)
|
||||
@@ -1498,10 +1489,7 @@ 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 +2019,6 @@ func TestUserActivityInsights_Golden(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2046,7 +2033,6 @@ 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,8 +2145,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,9 +2263,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,8 +2272,6 @@ func TestGenericInsights_RBAC(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run("AsOwner", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -844,8 +844,6 @@ func TestDetectorPushesLogs(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -149,12 +149,9 @@ 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()
|
||||
|
||||
|
||||
@@ -202,7 +202,6 @@ func TestCache_BuildTime(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -69,7 +69,6 @@ func TestInbox(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -1283,8 +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,8 +2004,6 @@ func TestNotificationTargetMatrix(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -68,8 +68,6 @@ func TestGoTemplate(t *testing.T) {
|
||||
}
|
||||
|
||||
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.Parallel()
|
||||
|
||||
|
||||
@@ -151,7 +151,6 @@ 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 +660,6 @@ 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 +802,6 @@ 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 +993,6 @@ 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)
|
||||
|
||||
@@ -110,7 +110,6 @@ func TestPagination(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
rw := httptest.NewRecorder()
|
||||
|
||||
@@ -420,7 +420,6 @@ func TestInProgressActions(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -650,7 +649,6 @@ func TestExpiredPrebuilds(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -78,7 +78,6 @@ 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)
|
||||
|
||||
@@ -587,8 +587,6 @@ func TestLabelsAggregation(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -29,8 +29,6 @@ func TestFilterAcceptableAgentLabels(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -99,7 +99,6 @@ func TestActiveUsers(t *testing.T) {
|
||||
},
|
||||
Count: 2,
|
||||
}} {
|
||||
tc := tc
|
||||
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},
|
||||
}} {
|
||||
tc := tc
|
||||
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,
|
||||
},
|
||||
}} {
|
||||
tc := tc
|
||||
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,
|
||||
},
|
||||
}} {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
registry := prometheus.NewRegistry()
|
||||
@@ -660,8 +656,6 @@ func TestExperimentsMetric(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
tc := tc
|
||||
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
reg := prometheus.NewRegistry()
|
||||
|
||||
@@ -155,7 +155,6 @@ func TestGithubRateLimits(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -466,7 +466,6 @@ 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)
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user