@@ -5,6 +5,8 @@ package ottlfuncs
55
66import (
77 "context"
8+ "errors"
9+ "fmt"
810 "reflect"
911 "testing"
1012
@@ -340,10 +342,20 @@ func Test_flatten(t *testing.T) {
340342 m := pcommon .NewMap ()
341343 err := m .FromRaw (tt .target )
342344 assert .NoError (t , err )
343- target := ottl.StandardPMapGetter [any ]{
345+ target := ottl.StandardGetSetter [any ]{
344346 Getter : func (_ context.Context , _ any ) (any , error ) {
345347 return m , nil
346348 },
349+ Setter : func (_ context.Context , tCtx any , m any ) error {
350+ fmt .Printf ("### %T %T\n " , tCtx , m )
351+ if v , ok := m .(pcommon.Map ); ok {
352+ if dst , ok2 := m .(pcommon.Map ); ok2 {
353+ v .CopyTo (dst )
354+ return nil
355+ }
356+ }
357+ return errors .New ("expected pcommon.Map" )
358+ },
347359 }
348360
349361 exprFunc , err := flatten [any ](target , tt .prefix , tt .depth , ottl.NewTestingOptional [bool ](tt .conflict ))
@@ -490,10 +502,19 @@ func Test_flatten_undeterministic(t *testing.T) {
490502 m := pcommon .NewMap ()
491503 err := m .FromRaw (tt .target )
492504 assert .NoError (t , err )
493- target := ottl.StandardPMapGetter [any ]{
505+ target := ottl.StandardGetSetter [any ]{
494506 Getter : func (_ context.Context , _ any ) (any , error ) {
495507 return m , nil
496508 },
509+ Setter : func (_ context.Context , tCtx any , m any ) error {
510+ if v , ok := m .(pcommon.Map ); ok {
511+ if dst , ok2 := tCtx .(pcommon.Map ); ok2 {
512+ v .CopyTo (dst )
513+ }
514+ return nil
515+ }
516+ return errors .New ("expected pcommon.Map" )
517+ },
497518 }
498519
499520 exprFunc , err := flatten [any ](target , tt .prefix , tt .depth , ottl.NewTestingOptional [bool ](tt .conflict ))
@@ -510,7 +531,7 @@ func Test_flatten_undeterministic(t *testing.T) {
510531}
511532
512533func Test_flatten_bad_target (t * testing.T ) {
513- target := & ottl.StandardPMapGetter [any ]{
534+ target := & ottl.StandardGetSetter [any ]{
514535 Getter : func (_ context.Context , _ any ) (any , error ) {
515536 return 1 , nil
516537 },
@@ -538,7 +559,7 @@ func Test_flatten_bad_depth(t *testing.T) {
538559
539560 for _ , tt := range tests {
540561 t .Run (tt .name , func (t * testing.T ) {
541- target := & ottl.StandardPMapGetter [any ]{
562+ target := & ottl.StandardGetSetter [any ]{
542563 Getter : func (_ context.Context , _ any ) (any , error ) {
543564 return pcommon .NewMap (), nil
544565 },
0 commit comments