-
-func TestNodebController_GetNodebIdList_Success_One(t *testing.T) {
- logger, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodebIdList_Success - failed to initialize logger, error: %s", err)
- }
-
- writer := httptest.NewRecorder()
-
- rnibReaderMock := mocks.RnibReaderMock{}
- var rnibError common.IRNibError
-
- enbList := []*entities.NbIdentity{}
- gnbList := []*entities.NbIdentity{&entities.NbIdentity{InventoryName: "test2", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId2", NbId: "nbId2"}}}
-
- rnibReaderMock.On("GetListEnbIds").Return(&enbList, rnibError)
- rnibReaderMock.On("GetListGnbIds").Return(&gnbList, rnibError)
-
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodebIdList(logger, writer, rnibReaderProvider)
- assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
- bodyBytes, err := ioutil.ReadAll(writer.Body)
- assert.Equal(t, "[{\"inventoryName\":\"test2\",\"globalNbId\":{\"plmnId\":\"plmnId2\",\"nbId\":\"nbId2\"}}]", string(bodyBytes))
-}
-
-func TestNodebController_GetNodebIdList_Success_Many(t *testing.T) {
- logger, err := logger.InitLogger(logger.InfoLevel)
-
- if err != nil {
- t.Errorf("#nodeb_controller_test.TestNodebController_GetNodebIdList_Success - failed to initialize logger, error: %s", err)
- }
-
- writer := httptest.NewRecorder()
-
- rnibReaderMock := mocks.RnibReaderMock{}
- var rnibError common.IRNibError
-
- enbList := []*entities.NbIdentity{&entities.NbIdentity{InventoryName: "test1", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId1", NbId: "nbId1"}}}
- gnbList := []*entities.NbIdentity{&entities.NbIdentity{InventoryName: "test2", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId2", NbId: "nbId2"}}, {InventoryName: "test3", GlobalNbId: &entities.GlobalNbId{PlmnId: "plmnId3", NbId: "nbId3"}}}
-
- rnibReaderMock.On("GetListEnbIds").Return(&enbList, rnibError)
- rnibReaderMock.On("GetListGnbIds").Return(&gnbList, rnibError)
-
- rnibReaderProvider := func() reader.RNibReader {
- return &rnibReaderMock
- }
-
- executeGetNodebIdList(logger, writer, rnibReaderProvider)
- assert.Equal(t, writer.Result().StatusCode, http.StatusOK)
- bodyBytes, err := ioutil.ReadAll(writer.Body)
- assert.Equal(t, "[{\"inventoryName\":\"test1\",\"globalNbId\":{\"plmnId\":\"plmnId1\",\"nbId\":\"nbId1\"}},{\"inventoryName\":\"test2\",\"globalNbId\":{\"plmnId\":\"plmnId2\",\"nbId\":\"nbId2\"}},{\"inventoryName\":\"test3\",\"globalNbId\":{\"plmnId\":\"plmnId3\",\"nbId\":\"nbId3\"}}]", string(bodyBytes))
-}