Files
traces/pkg/model/trace/sort_test.go
Javier Molina ReyesandGitHub cbc23d6a17 feat: rename batches property of Trace to ResourceSpans to be OTEL compatible (#3895)
* rename batches property of Trace to ResourceSpans to be OTEL compatible

* added test to assert that the response hasn't change

* update test data

* fix unmarshall test

* changelog

* fix e2e

* try to fix flaky test

* create helper functions to marshal and unmarshal traces to OTEL compatible schema

* added better documentation
2024-07-25 09:55:35 -04:00

83 lines
1.3 KiB
Go

package trace
import (
"testing"
"github.com/grafana/tempo/pkg/tempopb"
v1 "github.com/grafana/tempo/pkg/tempopb/trace/v1"
"github.com/stretchr/testify/assert"
)
func TestSortTrace(t *testing.T) {
tests := []struct {
input *tempopb.Trace
expected *tempopb.Trace
}{
{
input: &tempopb.Trace{},
expected: &tempopb.Trace{},
},
{
input: &tempopb.Trace{
ResourceSpans: []*v1.ResourceSpans{
{
ScopeSpans: []*v1.ScopeSpans{
{
Spans: []*v1.Span{
{
StartTimeUnixNano: 2,
},
},
},
},
},
{
ScopeSpans: []*v1.ScopeSpans{
{
Spans: []*v1.Span{
{
StartTimeUnixNano: 1,
},
},
},
},
},
},
},
expected: &tempopb.Trace{
ResourceSpans: []*v1.ResourceSpans{
{
ScopeSpans: []*v1.ScopeSpans{
{
Spans: []*v1.Span{
{
StartTimeUnixNano: 1,
},
},
},
},
},
{
ScopeSpans: []*v1.ScopeSpans{
{
Spans: []*v1.Span{
{
StartTimeUnixNano: 2,
},
},
},
},
},
},
},
},
}
for _, tt := range tests {
SortTrace(tt.input)
assert.Equal(t, tt.expected, tt.input)
}
}