chore(lint): enable tparallel linter (#23318)

Signed-off-by: Michael Crenshaw <350466+crenshaw-dev@users.noreply.github.com>
This commit is contained in:
Michael Crenshaw 2025-06-08 09:10:55 -04:00 committed by GitHub
parent 68c8b99270
commit 0fa3c3d67d
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
29 changed files with 129 additions and 2 deletions

View file

@ -26,6 +26,7 @@ linters:
- staticcheck
- testifylint
- thelper
- tparallel
- unparam
- usestdlibvars
- usetesting

View file

@ -180,6 +180,8 @@ foo:
}
func TestGitGenerateParamsFromDirectories(t *testing.T) {
t.Parallel()
cases := []struct {
name string
directories []v1alpha1.GitDirectoryGeneratorItem
@ -362,6 +364,8 @@ func TestGitGenerateParamsFromDirectories(t *testing.T) {
}
func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
t.Parallel()
cases := []struct {
name string
directories []v1alpha1.GitDirectoryGeneratorItem
@ -663,6 +667,8 @@ func TestGitGenerateParamsFromDirectoriesGoTemplate(t *testing.T) {
}
func TestGitGenerateParamsFromFiles(t *testing.T) {
t.Parallel()
cases := []struct {
name string
// files is the list of paths/globs to match
@ -1029,6 +1035,8 @@ cluster:
// TestGitGeneratorParamsFromFilesWithExcludeOptionWithNewGlobbing tests the params values generated by git file generator
// when exclude option is set to true. It gives the result files based on new globbing pattern - doublestar package
func TestGitGeneratorParamsFromFilesWithExcludeOptionWithNewGlobbing(t *testing.T) {
t.Parallel()
cases := []struct {
name string
// files is the list of paths/globs to match
@ -1373,6 +1381,8 @@ env: testing
// TestGitGeneratorParamsFromFilesWithExcludeOptionWithOldGlobbing tests the params values generated by git file generator
// // when exclude option is set to true. It gives the result files based on old globbing pattern - git ls-files
func TestGitGeneratorParamsFromFilesWithExcludeOptionWithOldGlobbing(t *testing.T) {
t.Parallel()
cases := []struct {
name string
// files is the list of paths/globs to match
@ -1712,6 +1722,8 @@ env: testing
// TestGitGeneratorParamsFromFilesWithExcludeOption tests the params values generated by git file generator
// when exclude option is set to true. It gives the result files based on new globbing pattern - doublestar package
func TestGitGeneratorParamsFromFilesWithExcludeOptionGoTemplate(t *testing.T) {
t.Parallel()
cases := []struct {
name string
// files is the list of paths/globs to match
@ -1943,6 +1955,8 @@ func TestGitGeneratorParamsFromFilesWithExcludeOptionGoTemplate(t *testing.T) {
}
func TestGitGenerateParamsFromFilesGoTemplate(t *testing.T) {
t.Parallel()
cases := []struct {
name string
// files is the list of paths/globs to match

View file

@ -50,6 +50,8 @@ func listOfMapsToSet(maps []map[string]any) (map[string]bool, error) {
}
func TestMergeGenerate(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
baseGenerators []argoprojiov1alpha1.ApplicationSetNestedGenerator
@ -210,6 +212,8 @@ func toAPIExtensionsJSON(t *testing.T, g any) *apiextensionsv1.JSON {
}
func TestParamSetsAreUniqueByMergeKeys(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
mergeKeys []string

View file

@ -275,6 +275,8 @@ func TestPullRequestGithubGenerateParams(t *testing.T) {
}
func TestAllowedSCMProviderPullRequest(t *testing.T) {
t.Parallel()
cases := []struct {
name string
providerConfig *argoprojiov1alpha1.PullRequestGenerator

View file

@ -12,6 +12,8 @@ import (
)
func TestSCMProviderGenerateParams(t *testing.T) {
t.Parallel()
cases := []struct {
name string
repos []*scm_provider.Repository
@ -185,6 +187,8 @@ func TestSCMProviderGenerateParams(t *testing.T) {
}
func TestAllowedSCMProvider(t *testing.T) {
t.Parallel()
cases := []struct {
name string
providerConfig *argoprojiov1alpha1.SCMProviderGenerator

View file

@ -13,6 +13,8 @@ import (
)
func Test_applyIgnoreDifferences(t *testing.T) {
t.Parallel()
appMeta := metav1.TypeMeta{
APIVersion: v1alpha1.ApplicationSchemaGroupVersionKind.GroupVersion().String(),
Kind: v1alpha1.ApplicationSchemaGroupVersionKind.Kind,

View file

@ -9,6 +9,8 @@ import (
)
func TestCombineStringMaps(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
left map[string]any

View file

@ -10,6 +10,8 @@ import (
)
func TestGetSignedRequestWithRetry(t *testing.T) {
t.Parallel()
ctx := t.Context()
t.Run("will return signed request on first attempt", func(t *testing.T) {

View file

@ -1218,6 +1218,8 @@ func Test_unset(t *testing.T) {
}
func Test_unset_nothingToUnset(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
source v1alpha1.ApplicationSource

View file

@ -14,6 +14,8 @@ import (
)
func Test_IsDefined(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
discover Discover
@ -76,6 +78,8 @@ func Test_IsDefined(t *testing.T) {
}
func Test_ReadPluginConfig(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
fileContents string
@ -169,6 +173,8 @@ spec:
}
func Test_PluginConfig_Address(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
config *PluginConfig

View file

@ -1301,6 +1301,8 @@ func TestComparisonResult_GetSyncStatus(t *testing.T) {
}
func TestIsLiveResourceManaged(t *testing.T) {
t.Parallel()
managedObj := kube.MustToUnstructured(&corev1.ConfigMap{
TypeMeta: metav1.TypeMeta{
APIVersion: "v1",

View file

@ -189,6 +189,8 @@ func TestSyncComparisonError(t *testing.T) {
}
func TestAppStateManager_SyncAppState(t *testing.T) {
t.Parallel()
type fixture struct {
application *v1alpha1.Application
controller *ApplicationController
@ -255,6 +257,8 @@ func TestAppStateManager_SyncAppState(t *testing.T) {
}
func TestSyncWindowDeniesSync(t *testing.T) {
t.Parallel()
type fixture struct {
application *v1alpha1.Application
controller *ApplicationController
@ -642,6 +646,8 @@ func TestNormalizeTargetResourcesWithList(t *testing.T) {
}
func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) {
t.Parallel()
type fixture struct {
project *v1alpha1.AppProject
application *v1alpha1.Application
@ -988,6 +994,8 @@ func TestDeriveServiceAccountMatchingNamespaces(t *testing.T) {
}
func TestDeriveServiceAccountMatchingServers(t *testing.T) {
t.Parallel()
type fixture struct {
project *v1alpha1.AppProject
application *v1alpha1.Application

View file

@ -947,6 +947,8 @@ func TestAppSourceEquality(t *testing.T) {
}
func TestAppSource_GetKubeVersionOrDefault(t *testing.T) {
t.Parallel()
defaultKV := "999.999.999"
cases := []struct {
name string
@ -996,6 +998,8 @@ func TestAppSource_GetKubeVersionOrDefault(t *testing.T) {
}
func TestAppSource_GetAPIVersionsOrDefault(t *testing.T) {
t.Parallel()
defaultAPIVersions := []string{"v1", "v2"}
cases := []struct {
name string
@ -1045,6 +1049,8 @@ func TestAppSource_GetAPIVersionsOrDefault(t *testing.T) {
}
func TestAppSource_GetNamespaceOrDefault(t *testing.T) {
t.Parallel()
defaultNS := "default"
cases := []struct {
name string
@ -2465,6 +2471,8 @@ func TestSyncWindows_Matches_AND_Operator(t *testing.T) {
}
func TestSyncWindows_CanSync(t *testing.T) {
t.Parallel()
t.Run("will allow manual sync if inactive-deny-window set with manual true", func(t *testing.T) {
// given
t.Parallel()
@ -4073,6 +4081,8 @@ func getApplicationSpec() *ApplicationSpec {
}
func TestGetSource(t *testing.T) {
t.Parallel()
tests := []struct {
name string
hasSources bool
@ -4102,6 +4112,8 @@ func TestGetSource(t *testing.T) {
}
func TestGetSources(t *testing.T) {
t.Parallel()
tests := []struct {
name string
hasSources bool
@ -4139,6 +4151,8 @@ func TestGetSources(t *testing.T) {
}
func TestOptionalArrayEquality(t *testing.T) {
t.Parallel()
// Demonstrate that the JSON unmarshalling of an empty array parameter is an OptionalArray with the array field set
// to an empty array.
presentButEmpty := `{"array":[]}`
@ -4182,6 +4196,8 @@ func TestOptionalArrayEquality(t *testing.T) {
}
func TestOptionalMapEquality(t *testing.T) {
t.Parallel()
// Demonstrate that the JSON unmarshalling of an empty map parameter is an OptionalMap with the map field set
// to an empty map.
presentButEmpty := `{"map":{}}`

View file

@ -228,6 +228,8 @@ func TestGenerateYamlManifestInDir(t *testing.T) {
}
func Test_GenerateManifests_NoOutOfBoundsAccess(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
outOfBoundsFilename string
@ -3312,6 +3314,8 @@ func TestGetHelmRepo_NamedReposAlias(t *testing.T) {
}
func Test_getResolvedValueFiles(t *testing.T) {
t.Parallel()
tempDir := t.TempDir()
paths := utilio.NewRandomizedTempPaths(tempDir)

View file

@ -172,6 +172,8 @@ func TestIsValidContainerNameName(t *testing.T) {
}
func TestTerminalHandler_ServeHTTP_empty_params(t *testing.T) {
t.Parallel()
testKeys := []string{
"pod",
"container",

View file

@ -131,6 +131,8 @@ func newEnforcer() *rbac.Enforcer {
}
func TestUpdateCluster_RejectInvalidParams(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
request cluster.ClusterUpdateRequest
@ -605,6 +607,8 @@ func getClientset(config map[string]string, ns string, objects ...runtime.Object
}
func TestListCluster(t *testing.T) {
t.Parallel()
db := &dbmocks.ArgoDB{}
fooCluster := v1alpha1.Cluster{

View file

@ -30,6 +30,8 @@ type deepLinkTC struct {
}
func TestDeepLinks(t *testing.T) {
t.Parallel()
appObj, err := kube.ToUnstructured(&v1alpha1.Application{
ObjectMeta: metav1.ObjectMeta{
Name: "test",

View file

@ -127,6 +127,8 @@ func TestValidateHeaders(t *testing.T) {
}
func TestRegisterExtensions(t *testing.T) {
t.Parallel()
type fixture struct {
settingsGetterMock *mocks.SettingsGetter
manager *extension.Manager
@ -231,6 +233,8 @@ func TestRegisterExtensions(t *testing.T) {
}
func TestCallExtension(t *testing.T) {
t.Parallel()
type fixture struct {
mux *http.ServeMux
appGetterMock *mocks.ApplicationGetter

View file

@ -672,6 +672,8 @@ connectors:
}
func TestGetClaims(t *testing.T) {
t.Parallel()
defaultExpiry := jwt.NewNumericDate(time.Now().Add(time.Hour * 24))
defaultExpiryUnix := float64(defaultExpiry.Unix())
@ -784,6 +786,8 @@ func TestGetClaims(t *testing.T) {
}
func TestAuthenticate_3rd_party_JWTs(t *testing.T) {
t.Parallel()
// Marshaling single strings to strings is typical, so we test for this relatively common behavior.
jwt.MarshalSingleStringAsArray = false
@ -943,6 +947,8 @@ func TestAuthenticate_3rd_party_JWTs(t *testing.T) {
}
func TestAuthenticate_no_request_metadata(t *testing.T) {
t.Parallel()
type testData struct {
test string
anonymousEnabled bool
@ -986,6 +992,8 @@ func TestAuthenticate_no_request_metadata(t *testing.T) {
}
func TestAuthenticate_no_SSO(t *testing.T) {
t.Parallel()
type testData struct {
test string
anonymousEnabled bool
@ -1035,6 +1043,8 @@ func TestAuthenticate_no_SSO(t *testing.T) {
}
func TestAuthenticate_bad_request_metadata(t *testing.T) {
t.Parallel()
type testData struct {
test string
anonymousEnabled bool
@ -1381,6 +1391,8 @@ func TestOIDCConfigChangeDetection_NoChange(t *testing.T) {
}
func TestIsMainJsBundle(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
url string
@ -1616,6 +1628,8 @@ func TestReplaceBaseHRef(t *testing.T) {
}
func Test_enforceContentTypes(t *testing.T) {
t.Parallel()
getBaseHandler := func(t *testing.T, allow bool) http.Handler {
t.Helper()
return http.HandlerFunc(func(writer http.ResponseWriter, _ *http.Request) {
@ -1624,9 +1638,9 @@ func Test_enforceContentTypes(t *testing.T) {
})
}
t.Parallel()
t.Run("GET - not providing a content type, should still succeed", func(t *testing.T) {
t.Parallel()
handler := enforceContentTypes(getBaseHandler(t, true), []string{"application/json"}).(http.HandlerFunc)
req := httptest.NewRequest(http.MethodGet, "/", nil)
w := httptest.NewRecorder()
@ -1636,6 +1650,8 @@ func Test_enforceContentTypes(t *testing.T) {
})
t.Run("POST", func(t *testing.T) {
t.Parallel()
handler := enforceContentTypes(getBaseHandler(t, true), []string{"application/json"}).(http.HandlerFunc)
req := httptest.NewRequest(http.MethodPost, "/", nil)
w := httptest.NewRecorder()

View file

@ -133,6 +133,8 @@ func getMultiSourceApp(annotation string, paths ...string) *v1alpha1.Application
}
func Test_AppFilesHaveChanged(t *testing.T) {
t.Parallel()
tests := []struct {
name string
app *v1alpha1.Application
@ -191,6 +193,8 @@ func Test_AppFilesHaveChanged(t *testing.T) {
}
func Test_GetAppRefreshPaths(t *testing.T) {
t.Parallel()
tests := []struct {
name string
app *v1alpha1.Application

View file

@ -23,6 +23,8 @@ import (
)
func TestSecretsRepositoryBackend_CreateRepository(t *testing.T) {
t.Parallel()
type fixture struct {
clientSet *fake.Clientset
repoBackend *secretsRepositoryBackend

View file

@ -57,6 +57,8 @@ func TestRunWithExecRunOpts(t *testing.T) {
}
func Test_getCommandArgsToLog(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
args []string

View file

@ -19,6 +19,8 @@ import (
)
func TestTgz(t *testing.T) {
t.Parallel()
type fixture struct {
file *os.File
}

View file

@ -9,6 +9,8 @@ import (
)
func TestRelativePath(t *testing.T) {
t.Parallel()
type testcase struct {
name string
fullpath string
@ -91,6 +93,8 @@ func TestRelativePath(t *testing.T) {
}
func TestInbound(t *testing.T) {
t.Parallel()
type testcase struct {
name string
candidate string

View file

@ -7,6 +7,8 @@ import (
)
func Test_IsNamespaceEnabled(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
namespace string

View file

@ -12,6 +12,8 @@ import (
)
func Test_UnverifiedHasAudClaim(t *testing.T) {
t.Parallel()
tokenForAud := func(t *testing.T, aud jwt.ClaimStrings) string {
t.Helper()
claims := jwt.RegisteredClaims{Audience: aud, Subject: "admin", ExpiresAt: jwt.NewNumericDate(time.Now().Add(time.Hour * 24))}

View file

@ -7,6 +7,8 @@ import (
)
func Test_AppRBACName(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
defaultNS string

View file

@ -1578,6 +1578,8 @@ rootCA: "invalid"`},
}
func Test_OAuth2AllowedAudiences(t *testing.T) {
t.Parallel()
testCases := []struct {
name string
settings *ArgoCDSettings

View file

@ -549,6 +549,8 @@ func TestUnknownEvent(t *testing.T) {
}
func TestAppRevisionHasChanged(t *testing.T) {
t.Parallel()
getSource := func(targetRevision string) v1alpha1.ApplicationSource {
return v1alpha1.ApplicationSource{TargetRevision: targetRevision}
}
@ -588,6 +590,8 @@ func TestAppRevisionHasChanged(t *testing.T) {
}
func Test_affectedRevisionInfo_appRevisionHasChanged(t *testing.T) {
t.Parallel()
sourceWithRevision := func(targetRevision string) v1alpha1.ApplicationSource {
return v1alpha1.ApplicationSource{TargetRevision: targetRevision}
}
@ -713,6 +717,8 @@ func Test_affectedRevisionInfo_appRevisionHasChanged(t *testing.T) {
}
func Test_GetWebURLRegex(t *testing.T) {
t.Parallel()
tests := []struct {
shouldMatch bool
webURL string
@ -767,6 +773,8 @@ func Test_GetWebURLRegex(t *testing.T) {
}
func Test_GetAPIURLRegex(t *testing.T) {
t.Parallel()
tests := []struct {
shouldMatch bool
apiURL string