From: naman.gupta Date: Tue, 6 Dec 2022 15:07:38 +0000 (+0530) Subject: UT for Get Policy instance Meta data X-Git-Tag: 3.0.0~10 X-Git-Url: https://gerrit.o-ran-sc.org/r/gitweb?a=commitdiff_plain;h=644ae0afdf53d629e52d122a2e2f5a9cd1432224;p=ric-plt%2Fa1.git UT for Get Policy instance Meta data UT for Get Policy instance Meta data Signed-off-by: naman.gupta Change-Id: I530e8284eb2480c90f9d533a51ca2143d77c342c --- 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 }