Skip to content

Commit

Permalink
testifylint: fixes with upstream version (#19049)
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Jul 15, 2024
1 parent c6f2d28 commit ed336c2
Show file tree
Hide file tree
Showing 13 changed files with 26 additions and 33 deletions.
2 changes: 1 addition & 1 deletion cmd/argocd/commands/admin/project_allowlist_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,5 +17,5 @@ func TestProjectAllowListGen(t *testing.T) {

globalProj, err := generateProjectAllowList(resourceList, "testdata/test_clusterrole.yaml", "testproj")
require.NoError(t, err)
assert.Positive(t, len(globalProj.Spec.NamespaceResourceWhitelist))
assert.NotEmpty(t, globalProj.Spec.NamespaceResourceWhitelist)
}
5 changes: 2 additions & 3 deletions cmd/util/cluster_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package util

import (
"strings"
"testing"

"github.com/stretchr/testify/assert"
Expand Down Expand Up @@ -53,8 +52,8 @@ func Test_newCluster(t *testing.T) {
&v1alpha1.AWSAuthConfig{},
&v1alpha1.ExecProviderConfig{}, labels, nil)

assert.True(t, strings.Contains(string(clusterWithFiles.Config.CertData), "test-cert-data"))
assert.True(t, strings.Contains(string(clusterWithFiles.Config.KeyData), "test-key-data"))
assert.Contains(t, string(clusterWithFiles.Config.CertData), "test-cert-data")
assert.Contains(t, string(clusterWithFiles.Config.KeyData), "test-key-data")
assert.Equal(t, "", clusterWithFiles.Config.BearerToken)
assert.Equal(t, labels, clusterWithFiles.Labels)
assert.Nil(t, clusterWithFiles.Annotations)
Expand Down
2 changes: 1 addition & 1 deletion controller/metrics/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -380,7 +380,7 @@ func assertMetricsNotPrinted(t *testing.T, expectedLines, body string) {
if line == "" {
continue
}
assert.False(t, strings.Contains(body, expectedLines))
assert.NotContains(t, body, expectedLines)
}
}

Expand Down
3 changes: 1 addition & 2 deletions pkg/apis/application/v1alpha1/types_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import (
"os"
"path"
"reflect"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -443,7 +442,7 @@ func TestAppProject_IsDestinationPermitted_PermitOnlyProjectScopedClusters(t *te
return nil, errors.New("some error")
})
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "could not retrieve project clusters"))
assert.Contains(t, err.Error(), "could not retrieve project clusters")
}

func TestAppProject_IsGroupKindPermitted(t *testing.T) {
Expand Down
3 changes: 1 addition & 2 deletions reposerver/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"encoding/json"
"errors"
"fmt"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -337,7 +336,7 @@ func TestCachedManifestResponse_ShallowCopyExpectedFields(t *testing.T) {
// go do that first :)

for _, expectedField := range expectedFields {
assert.Truef(t, strings.Contains(string(str), "\""+expectedField+"\""), "Missing field: %s", expectedField)
assert.Containsf(t, string(str), "\""+expectedField+"\"", "Missing field: %s", expectedField)
}
}

Expand Down
2 changes: 1 addition & 1 deletion reposerver/repository/repository_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -340,7 +340,7 @@ func TestGenerateManifests_EmptyCache(t *testing.T) {

res, err := service.GenerateManifest(context.Background(), &q)
require.NoError(t, err)
assert.Positive(t, len(res.Manifests))
assert.NotEmpty(t, res.Manifests)
mockCache.mockCache.AssertCacheCalledTimes(t, &repositorymocks.CacheCallCounts{
ExternalSets: 2,
ExternalGets: 2,
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/accounts_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package e2e

import (
"context"
"strings"
"testing"

"github.com/argoproj/pkg/errors"
Expand Down Expand Up @@ -50,7 +49,7 @@ func TestCanIGetLogsAllowNoSwitch(t *testing.T) {
CanIGetLogs().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "yes"))
assert.Contains(t, output, "yes")
})
}

Expand All @@ -65,7 +64,7 @@ func TestCanIGetLogsDenySwitchOn(t *testing.T) {
CanIGetLogs().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "no"))
assert.Contains(t, output, "no")
})
}

Expand Down Expand Up @@ -93,7 +92,7 @@ func TestCanIGetLogsAllowSwitchOn(t *testing.T) {
CanIGetLogs().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "yes"))
assert.Contains(t, output, "yes")
})
}

Expand All @@ -108,7 +107,7 @@ func TestCanIGetLogsAllowSwitchOff(t *testing.T) {
CanIGetLogs().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "yes"))
assert.Contains(t, output, "yes")
})
}

Expand Down
3 changes: 1 addition & 2 deletions test/e2e/app_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@ import (
"context"
"fmt"
"reflect"
"regexp"
"testing"
"time"

Expand Down Expand Up @@ -770,7 +769,7 @@ func assetSecretDataHidden(t *testing.T, manifest string) {
require.NoError(t, err)
assert.True(t, hasData)
for _, v := range secretData {
assert.Regexp(t, regexp.MustCompile(`[*]*`), v)
assert.Regexp(t, `[*]*`, v)
}
var lastAppliedConfigAnnotation string
annotations := secret.GetAnnotations()
Expand Down
5 changes: 2 additions & 3 deletions test/e2e/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@ package e2e
import (
"fmt"
"net/url"
"strings"
"testing"
"time"

Expand Down Expand Up @@ -171,8 +170,8 @@ func TestClusterSet(t *testing.T) {
GetByName("in-cluster").
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "namespace-edit-1"))
assert.True(t, strings.Contains(output, "namespace-edit-2"))
assert.Contains(t, output, "namespace-edit-1")
assert.Contains(t, output, "namespace-edit-2")
})
}

Expand Down
10 changes: 5 additions & 5 deletions test/e2e/project_management_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -164,21 +164,21 @@ func TestAddProjectDestination(t *testing.T) {
"test1",
)
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "already defined"))
assert.Contains(t, err.Error(), "already defined")

_, err = fixture.RunCli("proj", "add-destination", projectName,
"!*",
"test1",
)
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "server has an invalid format, '!*'"))
assert.Contains(t, err.Error(), "server has an invalid format, '!*'")

_, err = fixture.RunCli("proj", "add-destination", projectName,
"https://192.168.99.100:8443",
"!*",
)
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "namespace has an invalid format, '!*'"))
assert.Contains(t, err.Error(), "namespace has an invalid format, '!*'")

proj, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.TestNamespace()).Get(context.Background(), projectName, metav1.GetOptions{})
require.NoError(t, err)
Expand Down Expand Up @@ -383,7 +383,7 @@ func TestUseJWTToken(t *testing.T) {

roleGetResult, err = fixture.RunCli("proj", "role", "get", projectName, roleName)
require.NoError(t, err)
assert.True(t, strings.Contains(roleGetResult, strconv.FormatInt(newProj.Status.JWTTokensByRole[roleName].Items[0].IssuedAt, 10)))
assert.Contains(t, roleGetResult, strconv.FormatInt(newProj.Status.JWTTokensByRole[roleName].Items[0].IssuedAt, 10))

_, err = fixture.RunCli("proj", "role", "delete-token", projectName, roleName, strconv.FormatInt(newProj.Status.JWTTokensByRole[roleName].Items[0].IssuedAt, 10))
require.NoError(t, err)
Expand Down Expand Up @@ -420,7 +420,7 @@ func TestAddOrphanedIgnore(t *testing.T) {
"name",
)
require.Error(t, err)
assert.True(t, strings.Contains(err.Error(), "already defined"))
assert.Contains(t, err.Error(), "already defined")

proj, err := fixture.AppClientset.ArgoprojV1alpha1().AppProjects(fixture.TestNamespace()).Get(context.Background(), projectName, metav1.GetOptions{})
require.NoError(t, err)
Expand Down
9 changes: 4 additions & 5 deletions test/e2e/scoped_repository_test.go
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
package e2e

import (
"strings"
"testing"

"github.com/argoproj/argo-cd/v2/test/e2e/fixture"
Expand Down Expand Up @@ -57,7 +56,7 @@ func TestCreateRepositoryNonAdminUserPermissionDenied(t *testing.T) {
Create().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: repositories, create"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied: repositories, create")
})
}

Expand All @@ -84,7 +83,7 @@ func TestCreateRepositoryNonAdminUserWithWrongProject(t *testing.T) {
Create().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: repositories, create"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied: repositories, create")
})
}

Expand Down Expand Up @@ -127,7 +126,7 @@ func TestDeleteRepositoryRbacAllowed(t *testing.T) {
Delete().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(output, "Repository 'https://github.com/argoproj/argo-cd.git' removed"))
assert.Contains(t, output, "Repository 'https://github.com/argoproj/argo-cd.git' removed")
})
}

Expand Down Expand Up @@ -171,7 +170,7 @@ func TestDeleteRepositoryRbacDenied(t *testing.T) {
Delete().
Then().
AndCLIOutput(func(output string, err error) {
assert.True(t, strings.Contains(err.Error(), "PermissionDenied desc = permission denied: repositories, delete"))
assert.Contains(t, err.Error(), "PermissionDenied desc = permission denied: repositories, delete")
})
}

Expand Down
2 changes: 1 addition & 1 deletion util/db/cluster_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -279,7 +279,7 @@ func runWatchTest(t *testing.T, db ArgoDB, actions []func(old *v1alpha1.Cluster,
}

go func() {
require.NoError(t, db.WatchClusters(ctx, func(cluster *v1alpha1.Cluster) {
assert.NoError(t, db.WatchClusters(ctx, func(cluster *v1alpha1.Cluster) {
doNext(nil, cluster)
}, func(oldCluster *v1alpha1.Cluster, newCluster *v1alpha1.Cluster) {
doNext(oldCluster, newCluster)
Expand Down
4 changes: 2 additions & 2 deletions util/manifeststream/stream_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ func TestManifestStream(t *testing.T) {

go func() {
err := manifeststream.SendApplicationManifestQueryWithFiles(context.Background(), appStreamMock, "test", "test", appDir, nil)
require.NoError(t, err)
assert.NoError(t, err)
appStreamMock.done <- true
}()

Expand All @@ -102,7 +102,7 @@ func TestManifestStream(t *testing.T) {

go func() {
err = manifeststream.SendRepoStream(repoStreamMock, appStreamMock, req, *query.Checksum)
require.NoError(t, err)
assert.NoError(t, err)
repoStreamMock.done <- true
}()

Expand Down

0 comments on commit ed336c2

Please sign in to comment.