Skip to content

Commit

Permalink
Add unit test for the fix
Browse files Browse the repository at this point in the history
Test the case when eventing CR changes but NATS sub manager failed to
start
  • Loading branch information
muralov committed Nov 16, 2023
1 parent 98210c1 commit 1cb1e39
Showing 1 changed file with 30 additions and 0 deletions.
30 changes: 30 additions & 0 deletions internal/controller/eventing/nats_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,36 @@ func Test_reconcileNATSSubManager(t *testing.T) {
wantAssertCheck: true,
wantHashAfter: int64(-7550677537009891034),
},
{
name: "it should update the subscription manager when the backend config changes" +
"but subscription manager failed to start",
givenIsNATSSubManagerStarted: false,
givenHashBefore: int64(-8550677537009891034),
givenUpdateTest: true,
givenNATSSubManagerMock: func() *submanagermocks.Manager {
jetStreamSubManagerMock := new(submanagermocks.Manager)
jetStreamSubManagerMock.On("Init", mock.Anything).Return(nil).Once()
jetStreamSubManagerMock.On("Start", mock.Anything, mock.Anything).Return(nil).Once()
return jetStreamSubManagerMock
},
givenEventingManagerMock: func() *managermocks.Manager {
emMock := new(managermocks.Manager)
emMock.On("GetBackendConfig").Return(givenBackendConfig).Twice()
return emMock
},
givenNatsConfigHandlerMock: func() *mocks.NatsConfigHandler {
nchMock := new(mocks.NatsConfigHandler)
nchMock.On("GetNatsConfig", mock.Anything, mock.Anything).Return(givenNATSConfig, nil)
return nchMock
},
givenManagerFactoryMock: func(subManager *submanagermocks.Manager) *subscriptionmanagermocks.ManagerFactory {
subManagerFactoryMock := new(subscriptionmanagermocks.ManagerFactory)
subManagerFactoryMock.On("NewJetStreamManager", mock.Anything, mock.Anything).Return(subManager).Once()
return subManagerFactoryMock
},
wantAssertCheck: true,
wantHashAfter: int64(-7550677537009891034),
},
}

// run test cases
Expand Down

0 comments on commit 1cb1e39

Please sign in to comment.