Skip to content

Commit

Permalink
Enable goerr113 linting for EventMesh tests (#378)
Browse files Browse the repository at this point in the history
* Enable goerr113 linting for EventMesh tests

* Fix linting errors

* Rename ErrFailedToSyncEPPSecret name
  • Loading branch information
muralov authored Jan 11, 2024
1 parent 56b5217 commit f662163
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions internal/controller/operator/eventing/eventmesh_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,14 @@ const (
)

var (
ErrFailedToStart = errors.New("failed to start")
ErrFailedToStop = errors.New("failed to stop")
ErrFailedToRemove = errors.New("failed to remove")
errNotFound = errors.New("secret not found")
ErrFailedToStart = errors.New("failed to start")
ErrFailedToStop = errors.New("failed to stop")
ErrFailedToRemove = errors.New("failed to remove")
errNotFound = errors.New("secret not found")
ErrFailedToApplyPatch = errors.New("failed to apply patch")
ErrFailedToSyncPPSecret = errors.New("failed to sync Publisher Proxy secret: failed to apply patch")
)

//nolint:goerr113 // all tests here need to be fixed, as they use require.ErrorAs and use it wrongly
func Test_reconcileEventMeshSubManager(t *testing.T) {
t.Parallel()

Expand Down Expand Up @@ -124,10 +125,10 @@ func Test_reconcileEventMeshSubManager(t *testing.T) {
mockKubeClient := new(k8smocks.Client)
mockKubeClient.On("GetSecret", ctx, mock.Anything, mock.Anything).Return(
utils.NewOAuthSecret("test-secret", givenEventing.Namespace), nil).Once()
mockKubeClient.On("PatchApply", ctx, mock.Anything).Return(errors.New("failed to apply patch")).Once()
mockKubeClient.On("PatchApply", ctx, mock.Anything).Return(ErrFailedToApplyPatch).Once()
return mockKubeClient
},
wantError: errors.New("failed to sync Publisher Proxy secret: failed to apply patch"),
wantError: ErrFailedToSyncPPSecret,
},
{
name: "it should do nothing because subscription manager is already started",
Expand Down Expand Up @@ -196,7 +197,7 @@ func Test_reconcileEventMeshSubManager(t *testing.T) {
givenEventMeshSubManagerMock: func() *submgrmanagermocks.Manager {
eventMeshSubManagerMock := new(submgrmanagermocks.Manager)
eventMeshSubManagerMock.On("Init", mock.Anything).Return(nil).Once()
eventMeshSubManagerMock.On("Start", mock.Anything, mock.Anything).Return(errors.New("failed to start")).Twice()
eventMeshSubManagerMock.On("Start", mock.Anything, mock.Anything).Return(ErrFailedToStart).Twice()
return eventMeshSubManagerMock
},
givenEventingManagerMock: func() *eventingmocks.Manager {
Expand All @@ -218,7 +219,7 @@ func Test_reconcileEventMeshSubManager(t *testing.T) {
},
wantAssertCheck: true,
givenShouldRetry: true,
wantError: errors.New("failed to start"),
wantError: ErrFailedToStart,
wantHashAfter: int64(0),
},
{
Expand Down

0 comments on commit f662163

Please sign in to comment.