X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=cmd%2Fappmgr%2Fapi_test.go;h=2648dee50e5e4eb0e8d0e4bedd7b57bd4073167b;hb=57d2a61e41861321b263fdeff5679671e36143ae;hp=89e4a0867b00c8d08092e413b7ace4e5a509b86b;hpb=10d3c67188dd2db001e0fd196b0acbad7d9bb37d;p=ric-plt%2Fappmgr.git diff --git a/cmd/appmgr/api_test.go b/cmd/appmgr/api_test.go index 89e4a08..2648dee 100755 --- a/cmd/appmgr/api_test.go +++ b/cmd/appmgr/api_test.go @@ -41,9 +41,6 @@ var helmError error type MockedHelmer struct { } -func (h *MockedHelmer) SetCM(cm ConfigMapper) { -} - func (sd *MockedHelmer) Initialize() { } @@ -59,7 +56,7 @@ func (h *MockedHelmer) List() (names []string, err error) { return names, helmError } -func (h *MockedHelmer) Install(m XappDeploy) (Xapp, error) { +func (h *MockedHelmer) Install(m ConfigMetadata) (Xapp, error) { return xapp, helmError } @@ -74,10 +71,9 @@ func TestMain(m *testing.M) { xapp = Xapp{} xapps = []Xapp{} - cm := MockedConfigMapper{} h := MockedHelmer{} x = XappManager{} - x.Initialize(&h, &cm) + x.Initialize(&h) // Just run on the background (for coverage) go x.Run() @@ -158,36 +154,6 @@ func TestDeleteAppRemovesGivenXapp(t *testing.T) { checkResponseCode(t, http.StatusNotFound, response.Code) } -func TestGetConfigReturnsEmpty(t *testing.T) { - req, _ := http.NewRequest("GET", "/ric/v1/config", nil) - response := executeRequest(req) - - checkResponseCode(t, http.StatusOK, response.Code) -} - -func TestCreateConfigFailsWithMethodNotAllowed(t *testing.T) { - req, _ := http.NewRequest("POST", "/ric/v1/config", nil) - response := executeRequest(req) - - checkResponseCode(t, http.StatusMethodNotAllowed, response.Code) -} - -func TestCreateConfigOk(t *testing.T) { - payload := []byte(`{"name":"dummy-xapp"}`) - req, _ := http.NewRequest("POST", "/ric/v1/config", bytes.NewBuffer(payload)) - response := executeRequest(req) - - checkResponseCode(t, http.StatusCreated, response.Code) -} - -func TestDeleteConfigOk(t *testing.T) { - payload := []byte(`{"name":"dummy-xapp"}`) - req, _ := http.NewRequest("DELETE", "/ric/v1/config", bytes.NewBuffer(payload)) - response := executeRequest(req) - - checkResponseCode(t, http.StatusNotFound, response.Code) -} - // Error handling func TestGetXappReturnsError(t *testing.T) { helmError = errors.New("Not found") @@ -292,15 +258,13 @@ func generateXapp(name, status, ver, iname, istatus, ip, port string) (x Xapp) { x.Status = status x.Version = ver p, _ := strconv.Atoi(port) - var msgs MessageTypes - instance := XappInstance{ Name: iname, Status: istatus, Ip: ip, Port: p, - TxMessages: msgs.TxMessages, - RxMessages: msgs.RxMessages, + TxMessages: []string{"RIC_E2_TERMINATION_HC_REQUEST", "RIC_E2_MANAGER_HC_REQUEST"}, + RxMessages: []string{"RIC_E2_TERMINATION_HC_RESPONSE", "RIC_E2_MANAGER_HC_RESPONSE"}, } x.Instances = append(x.Instances, instance)