diff --git a/internal/controller/operator/eventing/eventmesh_test.go b/internal/controller/operator/eventing/eventmesh_test.go index 2b72cd24..5e9c7206 100644 --- a/internal/controller/operator/eventing/eventmesh_test.go +++ b/internal/controller/operator/eventing/eventmesh_test.go @@ -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() @@ -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", @@ -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 { @@ -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), }, {