@@ -8,12 +8,11 @@ import (
8
8
"testing"
9
9
10
10
"github.com/stretchr/testify/assert"
11
- "github.com/stretchr/testify/require"
12
11
13
12
"go.opentelemetry.io/collector/pdata/pcommon"
14
13
)
15
14
16
- func TestBuildAttributes (t * testing.T ) {
15
+ func TestFromAttributeIndices (t * testing.T ) {
17
16
profile := NewProfile ()
18
17
att := profile .AttributeTable ().AppendEmpty ()
19
18
att .SetKey ("hello" )
@@ -22,31 +21,29 @@ func TestBuildAttributes(t *testing.T) {
22
21
att2 .SetKey ("bonjour" )
23
22
att2 .Value ().SetStr ("monde" )
24
23
25
- attrs := BuildAttributes (profile , profile )
24
+ attrs := FromAttributeIndices (profile , profile )
26
25
assert .Equal (t , attrs , pcommon .NewMap ())
27
26
28
27
// A Location with a single attribute
29
28
loc := NewLocation ()
30
29
loc .AttributeIndices ().Append (0 )
31
30
32
- attrs = BuildAttributes (profile , loc )
31
+ attrs = FromAttributeIndices (profile , loc )
33
32
34
- m := pcommon .NewMap ()
35
- require .NoError (t , m .FromRaw (map [string ]any {"hello" : "world" }))
36
- assert .Equal (t , attrs , m )
33
+ m := map [string ]any {"hello" : "world" }
34
+ assert .Equal (t , attrs .AsRaw (), m )
37
35
38
36
// A Mapping with two attributes
39
37
mapp := NewLocation ()
40
38
mapp .AttributeIndices ().Append (0 , 1 )
41
39
42
- attrs = BuildAttributes (profile , mapp )
40
+ attrs = FromAttributeIndices (profile , mapp )
43
41
44
- m = pcommon .NewMap ()
45
- require .NoError (t , m .FromRaw (map [string ]any {"hello" : "world" , "bonjour" : "monde" }))
46
- assert .Equal (t , attrs , m )
42
+ m = map [string ]any {"hello" : "world" , "bonjour" : "monde" }
43
+ assert .Equal (t , attrs .AsRaw (), m )
47
44
}
48
45
49
- func BenchmarkBuildAttributes (b * testing.B ) {
46
+ func BenchmarkFromAttributeIndices (b * testing.B ) {
50
47
profile := NewProfile ()
51
48
52
49
for i := range 10 {
@@ -62,6 +59,6 @@ func BenchmarkBuildAttributes(b *testing.B) {
62
59
b .ReportAllocs ()
63
60
64
61
for n := 0 ; n < b .N ; n ++ {
65
- _ = BuildAttributes (profile , obj )
62
+ _ = FromAttributeIndices (profile , obj )
66
63
}
67
64
}
0 commit comments