@@ -11,6 +11,7 @@ import (
1111 "github.com/stretchr/testify/assert"
1212 "github.com/stretchr/testify/require"
1313
14+ "github.com/smartcontractkit/chainlink-common/pkg/contexts"
1415 "github.com/smartcontractkit/chainlink-protos/cre/go/values"
1516)
1617
@@ -331,3 +332,31 @@ func TestChainSelectorLabel(t *testing.T) {
331332}
332333
333334func ptr [T any ](v T ) * T { return & v }
335+
336+ func TestRequestMetadata_ContextWithCRE (t * testing.T ) {
337+ ctx := t .Context ()
338+ require .Equal (t , "" , contexts .CREValue (ctx ).Org )
339+
340+ // set it
341+ ctx = contexts .WithCRE (ctx , contexts.CRE {Org : "org-id" })
342+ require .Equal (t , "org-id" , contexts .CREValue (ctx ).Org )
343+
344+ // preserve it
345+ md := RequestMetadata {WorkflowOwner : "owner-id" , WorkflowID : "workflow-id" }
346+ ctx = md .ContextWithCRE (ctx )
347+ require .Equal (t , "org-id" , contexts .CREValue (ctx ).Org )
348+ }
349+
350+ func TestRegistrationMetadata_ContextWithCRE (t * testing.T ) {
351+ ctx := t .Context ()
352+ require .Equal (t , "" , contexts .CREValue (ctx ).Org )
353+
354+ // set it
355+ ctx = contexts .WithCRE (ctx , contexts.CRE {Org : "org-id" })
356+ require .Equal (t , "org-id" , contexts .CREValue (ctx ).Org )
357+
358+ // preserve it
359+ md := RegistrationMetadata {WorkflowOwner : "owner-id" , WorkflowID : "workflow-id" }
360+ ctx = md .ContextWithCRE (ctx )
361+ require .Equal (t , "org-id" , contexts .CREValue (ctx ).Org )
362+ }
0 commit comments