@@ -368,6 +368,39 @@ func TestEntitlementParitySuite(t *testing.T) {
368368 assert .Equal (t , v1ValueForV2ByKey , v2ValueForV2ByKey , "v1(by feature2Key) vs v2(by feature2Key) should match" )
369369 })
370370 })
371+
372+ t .Run ("Annotations and metadata parity (create and get)" , func (t * testing.T ) {
373+ t .Run ("Annotations created with V2 API should show up in V1 API" , func (t * testing.T ) {
374+ createGrantResponse , err := client .CreateCustomerEntitlementGrantV2WithResponse (ctx , customerID , feature1Key , api.CreateCustomerEntitlementGrantV2JSONRequestBody {
375+ Amount : 100 ,
376+ EffectiveAt : time .Now ().Truncate (time .Minute ).Add (time .Minute ),
377+ Expiration : nil ,
378+ Annotations : & api.Annotations {
379+ "some_annotation" : "some_annotation_value" ,
380+ },
381+ })
382+ require .NoError (t , err )
383+ require .Equal (t , http .StatusCreated , createGrantResponse .StatusCode (), "Invalid status code [response_body=%s]" , string (createGrantResponse .Body ))
384+
385+ getGrantResponse , err := client .ListEntitlementGrantsWithResponse (ctx , subjectKey , feature1Key , & api.ListEntitlementGrantsParams {})
386+ require .NoError (t , err )
387+ require .Equal (t , http .StatusOK , getGrantResponse .StatusCode (), "Invalid status code [response_body=%s]" , string (getGrantResponse .Body ))
388+ require .NotNil (t , getGrantResponse .JSON200 )
389+ require .GreaterOrEqual (t , len (lo .FromPtr (getGrantResponse .JSON200 )), 1 , "Invalid number of grants [response_body=%s]" , string (getGrantResponse .Body ))
390+
391+ var found * api.EntitlementGrant
392+
393+ for _ , grant := range lo .FromPtr (getGrantResponse .JSON200 ) {
394+ if grant .Id == createGrantResponse .JSON201 .Id {
395+ found = & grant
396+ break
397+ }
398+ }
399+
400+ require .NotNil (t , found , "Grant not found [response_body=%s]" , string (getGrantResponse .Body ))
401+ require .Equal (t , "some_annotation_value" , lo .FromPtr (found .Annotations )["some_annotation" ])
402+ })
403+ })
371404}
372405
373406func TestEntitlementDifferences (t * testing.T ) {
0 commit comments