Skip to content

Commit

Permalink
exporter/collector/integrationtest: fix lack of sort expectFixture field
Browse files Browse the repository at this point in the history
Fix: #421

Signed-off-by: Koichi Shiraishi <[email protected]>
  • Loading branch information
zchee committed Jun 28, 2022
1 parent 39a7dbd commit 132d6bc
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion exporter/collector/integrationtest/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ package integrationtest

import (
"context"
"sort"
"testing"
"time"

Expand Down Expand Up @@ -58,6 +59,15 @@ func TestMetrics(t *testing.T) {
startTime,
endTime,
)
sort.Slice(expectFixture.CreateTimeSeriesRequests, func(i, j int) bool {
return expectFixture.CreateTimeSeriesRequests[i].Name < expectFixture.CreateTimeSeriesRequests[j].Name
})
sort.Slice(expectFixture.CreateMetricDescriptorRequests, func(i, j int) bool {
return expectFixture.CreateMetricDescriptorRequests[i].Name < expectFixture.CreateMetricDescriptorRequests[j].Name
})
sort.Slice(expectFixture.CreateServiceTimeSeriesRequests, func(i, j int) bool {
return expectFixture.CreateServiceTimeSeriesRequests[i].Name < expectFixture.CreateServiceTimeSeriesRequests[j].Name
})

selfObsMetrics, err := inMemoryOCExporter.Proto(ctx)
require.NoError(t, err)
Expand All @@ -72,14 +82,23 @@ func TestMetrics(t *testing.T) {
fixture,
expectFixture,
func(i, j int) bool {
return fixture.CreateTimeSeriesRequests[i].Name > fixture.CreateTimeSeriesRequests[j].Name
return fixture.CreateTimeSeriesRequests[i].Name < fixture.CreateTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return fixture.CreateMetricDescriptorRequests[i].Name < fixture.CreateMetricDescriptorRequests[j].Name
},
func(i, j int) bool {
return fixture.CreateServiceTimeSeriesRequests[i].Name < fixture.CreateServiceTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateTimeSeriesRequests[i].Name < expectFixture.CreateTimeSeriesRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateMetricDescriptorRequests[i].Name < expectFixture.CreateMetricDescriptorRequests[j].Name
},
func(i, j int) bool {
return expectFixture.CreateServiceTimeSeriesRequests[i].Name < expectFixture.CreateServiceTimeSeriesRequests[j].Name
},
)
if diff != "" {
require.Fail(
Expand Down

0 comments on commit 132d6bc

Please sign in to comment.