"testing"
)
+const CHANNEL_NAME = "channel"
+
func setupRnibDataServiceTest(t *testing.T) (*rNibDataService, *mocks.RnibReaderMock, *mocks.RnibWriterMock) {
return setupRnibDataServiceTestWithMaxAttempts(t, 3)
}
t.Errorf("#... - failed to initialize logger, error: %s", err)
}
- config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: maxAttempts}
+ config := &configuration.Configuration{RnibRetryIntervalMs: 10, MaxRnibConnectionAttempts: maxAttempts, StateChangeMessageChannel: CHANNEL_NAME}
readerMock := &mocks.RnibReaderMock{}
assert.True(t, res)
}
+func TestSuccessfulUpdateNodebConnectivityState(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+ event := "event"
+
+ nodebInfo := &entities.NodebInfo{}
+ writerMock.On("UpdateNodebConnectivityState", nodebInfo, CHANNEL_NAME, event).Return(nil)
+
+ rnibDataService.UpdateNodebConnectivityState(nodebInfo, event)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebConnectivityState", 1)
+}
+
+func TestConnFailureUpdateNodebConnectivityState(t *testing.T) {
+ rnibDataService, _, writerMock := setupRnibDataServiceTest(t)
+ event := "event"
+
+ nodebInfo := &entities.NodebInfo{}
+ mockErr := &common.InternalError{Err: &net.OpError{Err: fmt.Errorf("connection error")}}
+ writerMock.On("UpdateNodebConnectivityState", nodebInfo, CHANNEL_NAME, event).Return(mockErr)
+
+ rnibDataService.UpdateNodebConnectivityState(nodebInfo, event)
+ writerMock.AssertNumberOfCalls(t, "UpdateNodebConnectivityState", 3)
+}
+
//func TestConnFailureThenSuccessGetNodebIdList(t *testing.T) {
// rnibDataService, readerMock, _ := setupRnibDataServiceTest(t)
//