Debian Codegraph @

trace/internal/telemetry/resource_test.go

raw
1 // Copyright The OpenTelemetry Authors
2 // SPDX-License-Identifier: Apache-2.0
3
4 package telemetry
5
6 import "testing"
7
8 func TestResourceEncoding(t *testing.T) {
9 res := &Resource{
10 Attrs: []Attr{String("key", "val")},
11 DroppedAttrs: 10,
12 }
13
14 t.Run("CamelCase", runJSONEncodingTests(res, []byte(`{
15 "attributes": [
16 {
17 "key": "key",
18 "value": {
19 "stringValue": "val"
20 }
21 }
22 ],
23 "droppedAttributesCount": 10
24 }`)))
25
26 t.Run("SnakeCase/Unmarshal", runJSONUnmarshalTest(res, []byte(`{
27 "attributes": [
28 {
29 "key": "key",
30 "value": {
31 "string_value": "val"
32 }
33 }
34 ],
35 "dropped_attributes_count": 10
36 }`)))
37 }