mirror of
https://github.com/hanzoai/telemetry.git
synced 2026-10-30 20:01:49 +00:00
Depends on https://github.com/open-telemetry/opentelemetry-collector/pull/11371 Signed-off-by: Bogdan Drutu <[email protected]>
33 lines
855 B
Go
33 lines
855 B
Go
// Copyright The OpenTelemetry Authors
|
|
// SPDX-License-Identifier: Apache-2.0
|
|
|
|
package otlptext
|
|
|
|
import (
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
"go.opentelemetry.io/collector/pdata/pcommon"
|
|
)
|
|
|
|
func TestNestedArraySerializesCorrectly(t *testing.T) {
|
|
ava := pcommon.NewValueSlice()
|
|
ava.Slice().AppendEmpty().SetStr("foo")
|
|
ava.Slice().AppendEmpty().SetInt(42)
|
|
ava.Slice().AppendEmpty().SetEmptySlice().AppendEmpty().SetStr("bar")
|
|
ava.Slice().AppendEmpty().SetBool(true)
|
|
ava.Slice().AppendEmpty().SetDouble(5.5)
|
|
|
|
assert.Equal(t, `Slice(["foo",42,["bar"],true,5.5])`, valueToString(ava))
|
|
}
|
|
|
|
func TestNestedMapSerializesCorrectly(t *testing.T) {
|
|
ava := pcommon.NewValueMap()
|
|
av := ava.Map()
|
|
av.PutStr("foo", "test")
|
|
av.PutEmptyMap("zoo").PutInt("bar", 13)
|
|
|
|
assert.Equal(t, `Map({"foo":"test","zoo":{"bar":13}})`, valueToString(ava))
|
|
}
|