Skip to content

Commit

Permalink
chore: enable error-is-as rule from testifylint linter (#18710)
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 Jun 18, 2024
1 parent 029b5ac commit 04edbe9
Show file tree
Hide file tree
Showing 7 changed files with 11 additions and 21 deletions.
1 change: 0 additions & 1 deletion .golangci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,6 @@ linters-settings:
testifylint:
enable-all: true
disable:
- error-is-as
- float-compare
- go-require
run:
Expand Down
8 changes: 2 additions & 6 deletions applicationset/generators/pull_request_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,6 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
cases := []struct {
name string
providerConfig *argoprojiov1alpha1.PullRequestGenerator
expectedError error
}{
{
name: "Error Github",
Expand All @@ -292,7 +291,6 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Gitlab",
Expand All @@ -301,7 +299,6 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Gitea",
Expand All @@ -310,7 +307,6 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Bitbucket",
Expand All @@ -319,7 +315,6 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
}

Expand Down Expand Up @@ -351,7 +346,8 @@ func TestAllowedSCMProviderPullRequest(t *testing.T) {
_, err := pullRequestGenerator.GenerateParams(&applicationSetInfo.Spec.Generators[0], &applicationSetInfo, nil)

require.Error(t, err, "Must return an error")
assert.ErrorAs(t, err, testCaseCopy.expectedError)
var expectedError ErrDisallowedSCMProvider
assert.ErrorAs(t, err, &expectedError)
})
}
}
Expand Down
9 changes: 2 additions & 7 deletions applicationset/generators/scm_provider_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,6 @@ func TestAllowedSCMProvider(t *testing.T) {
cases := []struct {
name string
providerConfig *argoprojiov1alpha1.SCMProviderGenerator
expectedError error
}{
{
name: "Error Github",
Expand All @@ -213,7 +212,6 @@ func TestAllowedSCMProvider(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Gitlab",
Expand All @@ -222,7 +220,6 @@ func TestAllowedSCMProvider(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Gitea",
Expand All @@ -231,7 +228,6 @@ func TestAllowedSCMProvider(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error Bitbucket",
Expand All @@ -240,7 +236,6 @@ func TestAllowedSCMProvider(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
{
name: "Error AzureDevops",
Expand All @@ -249,7 +244,6 @@ func TestAllowedSCMProvider(t *testing.T) {
API: "https://myservice.mynamespace.svc.cluster.local",
},
},
expectedError: &ErrDisallowedSCMProvider{},
},
}

Expand Down Expand Up @@ -284,7 +278,8 @@ func TestAllowedSCMProvider(t *testing.T) {
_, err := scmGenerator.GenerateParams(&applicationSetInfo.Spec.Generators[0], &applicationSetInfo, nil)

require.Error(t, err, "Must return an error")
assert.ErrorAs(t, err, testCaseCopy.expectedError)
var expectedError ErrDisallowedSCMProvider
assert.ErrorAs(t, err, &expectedError)
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion applicationset/services/repo_service_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -191,6 +191,6 @@ func TestNewArgoCDService(t *testing.T) {
service, err := NewArgoCDService(func(ctx context.Context, url, project string) (*v1alpha1.Repository, error) {
return &v1alpha1.Repository{}, nil
}, false, &repo_mocks.Clientset{}, false)
require.NoError(t, err, err)
require.NoError(t, err)
assert.NotNil(t, service)
}
6 changes: 3 additions & 3 deletions reposerver/cache/cache_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -613,7 +613,7 @@ func TestRevisionChartDetails(t *testing.T) {
fixtures := newFixtures()
t.Cleanup(fixtures.mockCache.StopRedisCallback)
details, err := fixtures.cache.GetRevisionChartDetails("test-repo", "test-revision", "v1.0.0")
require.ErrorAs(t, err, &ErrCacheMiss)
require.ErrorIs(t, err, ErrCacheMiss)
assert.Equal(t, &appv1.ChartDetails{}, details)
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
})
Expand Down Expand Up @@ -679,7 +679,7 @@ func TestGetGitDirectories(t *testing.T) {
fixtures := newFixtures()
t.Cleanup(fixtures.mockCache.StopRedisCallback)
directories, err := fixtures.cache.GetGitDirectories("test-repo", "test-revision")
require.ErrorAs(t, err, &ErrCacheMiss)
require.ErrorIs(t, err, ErrCacheMiss)
assert.Empty(t, directories)
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
})
Expand Down Expand Up @@ -733,7 +733,7 @@ func TestGetGitFiles(t *testing.T) {
fixtures := newFixtures()
t.Cleanup(fixtures.mockCache.StopRedisCallback)
directories, err := fixtures.cache.GetGitFiles("test-repo", "test-revision", "*.json")
require.ErrorAs(t, err, &ErrCacheMiss)
require.ErrorIs(t, err, ErrCacheMiss)
assert.Empty(t, directories)
fixtures.mockCache.AssertCacheCalledTimes(t, &mocks.CacheCallCounts{ExternalGets: 1})
})
Expand Down
4 changes: 2 additions & 2 deletions util/argo/resource_tracking_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,13 +156,13 @@ func TestParseAppInstanceValueColon(t *testing.T) {
func TestParseAppInstanceValueWrongFormat1(t *testing.T) {
resourceTracking := NewResourceTracking()
_, err := resourceTracking.ParseAppInstanceValue("app")
require.Error(t, err, WrongResourceTrackingFormat)
require.ErrorIs(t, err, WrongResourceTrackingFormat)
}

func TestParseAppInstanceValueWrongFormat2(t *testing.T) {
resourceTracking := NewResourceTracking()
_, err := resourceTracking.ParseAppInstanceValue("app;group/kind/ns")
require.Error(t, err, WrongResourceTrackingFormat)
require.ErrorIs(t, err, WrongResourceTrackingFormat)
}

func TestParseAppInstanceValueCorrectFormat(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion util/oidc/oidc_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ func TestGenerateAppState_XSS(t *testing.T) {
}

returnURL, err := app.verifyAppState(req, httptest.NewRecorder(), state)
require.NoError(t, err, InvalidRedirectURLError)
require.NoError(t, err)
assert.Equal(t, expectedReturnURL, returnURL)
})
}
Expand Down

0 comments on commit 04edbe9

Please sign in to comment.