Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Enable goerr113 linting for EventMesh tests #378

Merged
merged 3 commits into from
Jan 11, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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