mirror of
https://github.com/coder/coder.git
synced 2026-09-24 15:04:27 +08:00
chore: remove unnecessary redeclarations in for loops (#18440)
This commit is contained in:
@@ -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)
|
||||
|
||||
@@ -150,7 +150,6 @@ func TestAcquireJob(t *testing.T) {
|
||||
}},
|
||||
}
|
||||
for _, tc := range cases {
|
||||
tc := tc
|
||||
t.Run(tc.name+"_InitiatorNotFound", func(t *testing.T) {
|
||||
t.Parallel()
|
||||
srv, db, _, pd := setup(t, false, nil)
|
||||
@@ -176,7 +175,6 @@ func TestAcquireJob(t *testing.T) {
|
||||
sdkproto.PrebuiltWorkspaceBuildStage_CREATE,
|
||||
sdkproto.PrebuiltWorkspaceBuildStage_CLAIM,
|
||||
} {
|
||||
prebuiltWorkspaceBuildStage := prebuiltWorkspaceBuildStage
|
||||
t.Run(tc.name+"_WorkspaceBuildJob_Stage"+prebuiltWorkspaceBuildStage.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Set the max session token lifetime so we can assert we
|
||||
@@ -1709,8 +1707,6 @@ func TestCompleteJob(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2134,8 +2130,6 @@ func TestCompleteJob(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2579,7 +2573,6 @@ func TestInsertWorkspacePresetsAndParameters(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -132,7 +132,6 @@ func TestConvertProvisionerJob_Unit(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actual := convertProvisionerJob(database.GetProvisionerJobsByIDsWithQueuePositionRow{
|
||||
|
||||
@@ -243,7 +243,6 @@ func TestFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actor := tc.Actor
|
||||
@@ -1135,7 +1134,6 @@ func testAuthorize(t *testing.T, name string, subject Subject, sets ...[]authTes
|
||||
authorizer := NewAuthorizer(prometheus.NewRegistry())
|
||||
for _, cases := range sets {
|
||||
for i, c := range cases {
|
||||
c := c
|
||||
caseName := fmt.Sprintf("%s/%d", name, i)
|
||||
t.Run(caseName, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -165,7 +165,6 @@ func TestObjectEqual(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -265,7 +265,6 @@ neq(input.object.owner, "");
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
part := partialQueries(tc.Queries...)
|
||||
|
||||
@@ -114,7 +114,6 @@ func TestEquality(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -92,7 +92,6 @@ func TestMembership(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -229,7 +229,6 @@ func TestRoleByName(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Role.Identifier.String(), func(t *testing.T) {
|
||||
role, err := RoleByName(c.Role.Identifier)
|
||||
require.NoError(t, err, "role exists")
|
||||
|
||||
@@ -37,7 +37,6 @@ func (a authSubject) Subjects() []authSubject { return []authSubject{a} }
|
||||
func TestBuiltInRoles(t *testing.T) {
|
||||
t.Parallel()
|
||||
for _, r := range rbac.SiteBuiltInRoles() {
|
||||
r := r
|
||||
t.Run(r.Identifier.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.NoError(t, r.Valid(), "invalid role")
|
||||
@@ -45,7 +44,6 @@ func TestBuiltInRoles(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, r := range rbac.OrganizationRoles(uuid.New()) {
|
||||
r := r
|
||||
t.Run(r.Identifier.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.NoError(t, r.Valid(), "invalid role")
|
||||
@@ -896,7 +894,6 @@ func TestRolePermissions(t *testing.T) {
|
||||
passed := true
|
||||
// nolint:tparallel,paralleltest
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
// nolint:tparallel,paralleltest // These share the same remainingPermissions map
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
remainingSubjs := make(map[string]struct{})
|
||||
@@ -995,7 +992,6 @@ func TestIsOrgRole(t *testing.T) {
|
||||
|
||||
// nolint:paralleltest
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Identifier.String(), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ok := c.Identifier.IsOrgRole()
|
||||
@@ -1092,7 +1088,6 @@ func TestChangeSet(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -119,7 +119,6 @@ func TestSubjectEqual(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -79,8 +79,6 @@ func TestHTML(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -486,8 +486,6 @@ func TestCalculateAutoStop(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -622,7 +620,6 @@ func TestFindWeek(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tz := range timezones {
|
||||
tz := tz
|
||||
t.Run("Loc/"+tz, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -141,7 +141,6 @@ func Test_Weekly(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actual, err := cron.Weekly(testCase.spec)
|
||||
|
||||
@@ -297,7 +297,6 @@ func TestSearchWorkspace(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
// TODO: Replace this with the mock database.
|
||||
@@ -382,7 +381,6 @@ func TestSearchAudit(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Do not use a real database, this is only used for an
|
||||
@@ -550,7 +548,6 @@ func TestSearchUsers(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
values, errs := searchquery.Users(c.Query)
|
||||
@@ -622,7 +619,6 @@ func TestSearchTemplates(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
// Do not use a real database, this is only used for an
|
||||
|
||||
@@ -257,7 +257,6 @@ func TestServerTailnet_ReverseProxy(t *testing.T) {
|
||||
port := ":4444"
|
||||
|
||||
for i, ag := range agents {
|
||||
i := i
|
||||
ln, err := ag.TailnetConn().Listen("tcp", port)
|
||||
require.NoError(t, err)
|
||||
wln := &wrappedListener{Listener: ln}
|
||||
|
||||
@@ -544,7 +544,6 @@ func TestRecordTelemetryStatus(t *testing.T) {
|
||||
{name: "Telemetry was disabled still disabled", recordedTelemetryEnabled: "false", telemetryEnabled: false, shouldReport: false},
|
||||
{name: "Telemetry was disabled still disabled, invalid value", recordedTelemetryEnabled: "invalid", telemetryEnabled: false, shouldReport: false},
|
||||
} {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -604,7 +604,6 @@ func TestPostTemplateVersionsByOrganization(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
ctx := testutil.Context(t, testutil.WaitShort)
|
||||
@@ -1393,7 +1392,6 @@ func TestPaginatedTemplateVersions(t *testing.T) {
|
||||
file, err := client.Upload(egCtx, codersdk.ContentTypeTar, bytes.NewReader(data))
|
||||
require.NoError(t, err)
|
||||
for i := 0; i < total; i++ {
|
||||
i := i
|
||||
eg.Go(func() error {
|
||||
templateVersion, err := client.CreateTemplateVersion(egCtx, user.OrganizationID, codersdk.CreateTemplateVersionRequest{
|
||||
Name: uuid.NewString(),
|
||||
@@ -1466,7 +1464,6 @@ func TestPaginatedTemplateVersions(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -77,8 +77,6 @@ func Test_Middleware(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
name := strings.ReplaceAll(strings.TrimPrefix(c.path, "/"), "/", "_")
|
||||
t.Run(name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -112,7 +112,6 @@ func TestChecker_Latest(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -51,8 +51,6 @@ func TestUpdateCheck_NewVersion(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -1473,7 +1473,6 @@ func TestUserOIDC(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
opts := []oidctest.FakeIDPOpt{
|
||||
|
||||
@@ -27,7 +27,6 @@ func TestUserPasswordValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
err := userpassword.Validate(tt.password)
|
||||
@@ -93,7 +92,6 @@ func TestUserPasswordCompare(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
if tt.shouldHash {
|
||||
|
||||
@@ -1777,7 +1777,6 @@ func TestUsersFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2461,7 +2460,6 @@ func TestPaginatedUsers(t *testing.T) {
|
||||
eg, _ := errgroup.WithContext(ctx)
|
||||
// Create users
|
||||
for i := 0; i < total; i++ {
|
||||
i := i
|
||||
eg.Go(func() error {
|
||||
email := fmt.Sprintf("%d@coder.com", i)
|
||||
username := fmt.Sprintf("user%d", i)
|
||||
@@ -2519,7 +2517,6 @@ func TestPaginatedUsers(t *testing.T) {
|
||||
{name: "username search", limit: 3, allUsers: specialUsers, opt: usernameSearch},
|
||||
}
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(fmt.Sprintf("%s %d", tt.name, tt.limit), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -70,7 +70,6 @@ func TestSubset(t *testing.T) {
|
||||
expected: true,
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run("#"+strconv.Itoa(idx), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -30,7 +30,6 @@ func TestTruncate(t *testing.T) {
|
||||
{"foo", 0, ""},
|
||||
{"foo", -1, ""},
|
||||
} {
|
||||
tt := tt
|
||||
t.Run(tt.expected, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
actual := strings.Truncate(tt.s, tt.n)
|
||||
|
||||
@@ -107,7 +107,6 @@ func TestLimitWriter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -1065,7 +1065,6 @@ func TestWorkspaceAgentListeningPorts(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run("OK_"+tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1340,7 +1339,6 @@ func TestWorkspaceAgentContainers(t *testing.T) {
|
||||
},
|
||||
},
|
||||
} {
|
||||
tc := tc
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1692,7 +1690,6 @@ func TestWorkspaceAgent_LifecycleState(t *testing.T) {
|
||||
}
|
||||
//nolint:paralleltest // No race between setting the state and getting the workspace.
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(string(tt.state), func(t *testing.T) {
|
||||
state, err := agentsdk.ProtoFromLifecycleState(tt.state)
|
||||
if tt.wantErr {
|
||||
|
||||
@@ -500,8 +500,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
if c.name == "Path" && appHostIsPrimary {
|
||||
// Workspace application auth does not apply to path apps
|
||||
// served from the primary access URL as no smuggling needs
|
||||
@@ -1686,8 +1684,6 @@ func Run(t *testing.T, appHostIsPrimary bool, factory DeploymentFactory) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -56,7 +56,6 @@ func TestApplicationURLString(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -158,7 +157,6 @@ func TestParseSubdomainAppURL(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -378,7 +376,6 @@ func TestCompileHostnamePattern(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -390,7 +387,6 @@ func TestCompileHostnamePattern(t *testing.T) {
|
||||
require.Equal(t, expected, regex.String(), "generated regex does not match")
|
||||
|
||||
for i, m := range c.matchCases {
|
||||
m := m
|
||||
t.Run(fmt.Sprintf("MatchCase%d", i), func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -459,7 +455,6 @@ func TestConvertAppURLForCSP(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
require.Equal(t, c.expected, appurl.ConvertAppHostForCSP(c.host, c.wildcard))
|
||||
|
||||
@@ -270,8 +270,6 @@ func Test_ResolveRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -272,7 +272,6 @@ func Test_RequestValidate(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
req := c.req
|
||||
|
||||
@@ -280,7 +280,6 @@ func TestStatsCollector(t *testing.T) {
|
||||
|
||||
// Run tests.
|
||||
for _, tt := range tests {
|
||||
tt := tt
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -273,8 +273,6 @@ func Test_TokenMatchesRequest(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -57,7 +57,6 @@ func TestGetAppHost(t *testing.T) {
|
||||
},
|
||||
}
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -182,7 +181,6 @@ func TestWorkspaceApplicationAuth(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range cases {
|
||||
c := c
|
||||
t.Run(c.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -652,7 +652,6 @@ func TestWorkspace(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, tc := range testCases {
|
||||
tc := tc // Capture range variable
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -1802,7 +1801,6 @@ func TestWorkspaceFilter(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, c := range testCases {
|
||||
c := c
|
||||
t.Run(c.Name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
workspaces, err := client.Workspaces(ctx, c.Filter)
|
||||
@@ -2583,7 +2581,6 @@ func TestWorkspaceUpdateAutostart(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
var (
|
||||
@@ -2763,7 +2760,6 @@ func TestWorkspaceUpdateTTL(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
@@ -2864,8 +2860,6 @@ func TestWorkspaceUpdateTTL(t *testing.T) {
|
||||
}
|
||||
|
||||
for _, testCase := range testCases {
|
||||
testCase := testCase
|
||||
|
||||
t.Run(testCase.name, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
|
||||
|
||||
@@ -158,9 +158,7 @@ func Test_ActivityBumpWorkspace(t *testing.T) {
|
||||
expectedBump: 0,
|
||||
},
|
||||
} {
|
||||
tt := tt
|
||||
for _, tz := range timezones {
|
||||
tz := tz
|
||||
t.Run(tt.name+"/"+tz, func(t *testing.T) {
|
||||
t.Parallel()
|
||||
nextAutostart := tt.nextAutostart
|
||||
|
||||
Reference in New Issue
Block a user