X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=blobdiff_plain;f=a1-go%2Fpkg%2Fresthooks%2Fresthooks_test.go;h=a9fcc1e006a3e81797e9fee2eff1b772da7a87b0;hb=644ae0afdf53d629e52d122a2e2f5a9cd1432224;hp=8003df7b00b3f6553283b4cfc10e9ccedeb60d1f;hpb=521fb5516a4212246ff977a849dfd24f0c87b2a6;p=ric-plt%2Fa1.git diff --git a/a1-go/pkg/resthooks/resthooks_test.go b/a1-go/pkg/resthooks/resthooks_test.go index 8003df7..a9fcc1e 100644 --- a/a1-go/pkg/resthooks/resthooks_test.go +++ b/a1-go/pkg/resthooks/resthooks_test.go @@ -324,6 +324,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 }