Skip to content

Commit

Permalink
apply assert.ObjectsAreEqualValues
Browse files Browse the repository at this point in the history
  • Loading branch information
atoulme committed Dec 21, 2023
1 parent 50c0c12 commit 72ee27f
Showing 1 changed file with 2 additions and 11 deletions.
13 changes: 2 additions & 11 deletions tests/testutils/telemetry/metrics.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import (
"strings"

"github.com/knadh/koanf/maps"
"github.com/stretchr/testify/assert"
"gopkg.in/yaml.v2"

"github.com/signalfx/splunk-otel-collector/tests/internal/version"
Expand Down Expand Up @@ -256,23 +257,13 @@ func (metric Metric) equals(toCompare Metric, strict bool) bool {
return false
}

if !valuesEqual(metric.Value, toCompare.Value) && (strict || metric.Value != nil) {
if !assert.ObjectsAreEqualValues(metric.Value, toCompare.Value) && (strict || metric.Value != nil) {
return false
}

return attributesAreEqual(metric.Attributes, toCompare.Attributes)
}

func valuesEqual(value any, toCompare any) bool {
if i, ok := value.(int); ok {
value = int64(i)
}
if i, ok := toCompare.(int); ok {
toCompare = int64(i)
}
return value == toCompare
}

// FlattenResourceMetrics takes multiple instances of ResourceMetrics and flattens them
// to only unique entries by Resource, InstrumentationScope, and Metric content.
// It will preserve order by removing subsequent occurrences of repeated items
Expand Down

0 comments on commit 72ee27f

Please sign in to comment.