-func executeGetNodeb(logger *logger.Logger, writer *httptest.ResponseRecorder, rnibReaderProvider func() reader.RNibReader) {
- req, _ := http.NewRequest("GET", "/nodeb", nil)
- req = mux.SetURLVars(req, map[string]string{"ranName": "testNode"})
+func controllerGetNodebIdListTestExecuter(t *testing.T, context *controllerGetNodebIdListTestContext) {
+ controller, readerMock, _, _ := setupControllerTest(t)
+ writer := httptest.NewRecorder()
+ readerMock.On("GetListNodebIds").Return(context.nodebIdList, context.rnibError)
+ req, _ := http.NewRequest("GET", "/nodeb/ids", nil)
+ controller.GetNodebIdList(writer, req)
+ assert.Equal(t, context.expectedStatusCode, writer.Result().StatusCode)
+ bodyBytes, _ := ioutil.ReadAll(writer.Body)
+ assert.Equal(t, context.expectedJsonResponse, string(bodyBytes))
+}
+
+func TestControllerGetNodebSuccess(t *testing.T) {
+ ranName := "test"
+ var rnibError error
+ context := controllerGetNodebTestContext{
+ ranName: ranName,
+ nodebInfo: &entities.NodebInfo{RanName: ranName, Ip: "10.0.2.15", Port: 1234},
+ rnibError: rnibError,
+ expectedStatusCode: http.StatusOK,
+ expectedJsonResponse: fmt.Sprintf("{\"ranName\":\"%s\",\"ip\":\"10.0.2.15\",\"port\":1234}", ranName),
+ }