X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Fresthooks%2Fresthooks_test.go;h=ac3dc25ddf63e54cb4f17c87b99282ee54bab1af;hb=9f4fe4d725c9ad77ea1c2ab565ce5759e8a932a6;hp=6d7679e90cff0d440f3659adddab713b31c6833c;hpb=a5d992815f470a349dea86d616509222eb051f97;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/resthooks/resthooks_test.go b/a1-go/pkg/resthooks/resthooks_test.go index 6d7679e..ac3dc25 100644 --- a/a1-go/pkg/resthooks/resthooks_test.go +++ b/a1-go/pkg/resthooks/resthooks_test.go @@ -51,9 +51,9 @@ func TestMain(m *testing.M) { "a1.policy_type.20000", "a1.policy_inst_metadata.1006001.qos", }, nil) - RMRclient = new(RMRClientMock) + rmrSenderInst = new(RmrSenderMock) a1.Init() - rh = createResthook(sdlInst, RMRclient) + rh = createResthook(sdlInst, rmrSenderInst) code := m.Run() os.Exit(code) } @@ -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 }