type MockedHelmer struct {
}
+func (h *MockedHelmer) SetCM(cm ConfigMapper) {
+}
+
func (sd *MockedHelmer) Initialize() {
}
return names, helmError
}
-func (h *MockedHelmer) Install(m ConfigMetadata) (Xapp, error) {
+func (h *MockedHelmer) Install(m XappDeploy) (Xapp, error) {
return xapp, helmError
}
xapp = Xapp{}
xapps = []Xapp{}
+ cm := MockedConfigMapper{}
h := MockedHelmer{}
x = XappManager{}
- x.Initialize(&h)
+ x.Initialize(&h, &cm)
// Just run on the background (for coverage)
go x.Run()
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")
x.Status = status
x.Version = ver
p, _ := strconv.Atoi(port)
+ var msgs MessageTypes
+
instance := XappInstance{
Name: iname,
Status: istatus,
Ip: ip,
Port: p,
- TxMessages: []string{"RIC_E2_TERMINATION_HC_REQUEST", "RIC_E2_MANAGER_HC_REQUEST"},
- RxMessages: []string{"RIC_E2_TERMINATION_HC_RESPONSE", "RIC_E2_MANAGER_HC_RESPONSE"},
+ TxMessages: msgs.TxMessages,
+ RxMessages: msgs.RxMessages,
}
x.Instances = append(x.Instances, instance)