Moving RMR message reciver into go routine
[ric-plt/a1.git] / a1-go / pkg / resthooks / resthooks_test.go
index 8003df7..ac3dc25 100644 (file)
@@ -230,8 +230,9 @@ func TestGetPolicyInstanceStatus(t *testing.T) {
        keys[0] = instancekey
        sdlInst.On("Get", a1MediatorNs, keys[:]).Return(httpBody)
 
-       resp := rh.GetPolicyInstanceStatus(policyTypeId, policyInstanceID)
+       resp, errresp := rh.GetPolicyInstanceStatus(policyTypeId, policyInstanceID)
 
+       assert.Nil(t, errresp)
        assert.NotNil(t, resp)
        sdlInst.AssertExpectations(t)
 }
@@ -324,6 +325,31 @@ func TestDataDelivery(t *testing.T) {
        sdlInst.AssertExpectations(t)
 }
 
+func TestGetMetaData(t *testing.T) {
+       var policyTypeId models.PolicyTypeID
+       policyTypeId = 20001
+       var policyInstanceID models.PolicyInstanceID
+       policyInstanceID = "123456"
+       instanceMetadataKey := a1InstanceMetadataPrefix + strconv.FormatInt((int64(policyTypeId)), 10) + "." + string(policyInstanceID)
+       a1.Logger.Debug("key : %+v", instanceMetadataKey)
+
+       var keys [1]string
+       keys[0] = instanceMetadataKey
+
+       policySchemaString := `{
+               "created_at":"2022-11-02 10:30:20",
+               "instance_status":"NOT IN EFFECT"
+               }`
+
+       sdlInst.On("Get", a1MediatorNs, keys[:]).Return(map[string]interface{}{instanceMetadataKey: policySchemaString}, nil)
+
+       resp, errresp := rh.getMetaData(policyTypeId, policyInstanceID)
+
+       assert.Nil(t, errresp)
+       assert.NotNil(t, resp)
+       sdlInst.AssertExpectations(t)
+}
+
 type SdlMock struct {
        mock.Mock
 }