Skip to content

Commit

Permalink
[chore]: enable float-compare rule from testifylint
Browse files Browse the repository at this point in the history
Signed-off-by: Matthieu MOREL <matthieu.morel35@gmail.com>
  • Loading branch information
mmorel-35 committed Sep 19, 2024
1 parent 5601dfb commit e1785be
Show file tree
Hide file tree
Showing 70 changed files with 249 additions and 248 deletions.
1 change: 0 additions & 1 deletion .golangci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,6 @@ linters-settings:

testifylint:
disable:
- float-compare
- require-error
- suite-subtest-run
enable-all: true
Expand Down
2 changes: 1 addition & 1 deletion Makefile.Common
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ GOTESTSUM := $(TOOLS_BIN_DIR)/gotestsum
TESTIFYLINT := $(TOOLS_BIN_DIR)/testifylint

GOTESTSUM_OPT?= --rerun-fails=1
TESTIFYLINT_OPT?= --enable-all --disable=float-compare,require-error,suite-subtest-run
TESTIFYLINT_OPT?= --enable-all --disable=require-error,suite-subtest-run

# BUILD_TYPE should be one of (dev, release).
BUILD_TYPE?=release
Expand Down
4 changes: 2 additions & 2 deletions connector/routingconnector/metrics_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -219,7 +219,7 @@ func TestMetricsAreCorrectlySplitPerResourceAttributeWithOTTL(t *testing.T) {
rmetric := defaultSink.AllMetrics()[0].ResourceMetrics().At(0)
attr, ok := rmetric.Resource().Attributes().Get("value")
assert.True(t, ok, "routing attribute must exist")
assert.Equal(t, attr.Double(), float64(-1.0))
assert.InDelta(t, attr.Double(), float64(-1.0), 0.01)
})

t.Run("metric matched by one expression, multiple pipelines", func(t *testing.T) {
Expand Down Expand Up @@ -386,7 +386,7 @@ func TestMetricsAreCorrectlyMatchOnceWithOTTL(t *testing.T) {
rmetric := defaultSink.AllMetrics()[0].ResourceMetrics().At(0)
attr, ok := rmetric.Resource().Attributes().Get("value")
assert.True(t, ok, "routing attribute must exist")
assert.Equal(t, attr.Double(), float64(-1.0))
assert.InDelta(t, attr.Double(), float64(-1.0), 0.01)
})

t.Run("metric matched by one expression, multiple pipelines", func(t *testing.T) {
Expand Down
2 changes: 1 addition & 1 deletion connector/servicegraphconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -268,7 +268,7 @@ func verifyDuration(t *testing.T, m pmetric.Metric, durationSum float64, bs []ui
assert.Equal(t, 1, dps.Len())

dp := dps.At(0)
assert.Equal(t, durationSum, dp.Sum()) // Duration: client is 1sec, server is 2sec
assert.InDelta(t, durationSum, dp.Sum(), 0.01) // Duration: client is 1sec, server is 2sec
assert.Equal(t, uint64(1), dp.Count())
buckets := pcommon.NewUInt64Slice()
buckets.FromRaw(bs)
Expand Down
6 changes: 4 additions & 2 deletions connector/spanmetricsconnector/connector_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -221,10 +221,11 @@ func verifyExplicitHistogramDataPoints(t testing.TB, dps pmetric.HistogramDataPo
require.Equal(t, numDataPoints, dps.Len())
for dpi := 0; dpi < numDataPoints; dpi++ {
dp := dps.At(dpi)
assert.Equal(
assert.InDelta(
t,
sampleDuration*float64(numCumulativeConsumptions),
dp.Sum(),
0.01,
"Should be a 11ms duration measurement, multiplied by the number of stateful accumulations.")
assert.NotZero(t, dp.Timestamp(), "Timestamp should be set")

Expand Down Expand Up @@ -260,10 +261,11 @@ func verifyExponentialHistogramDataPoints(t testing.TB, dps pmetric.ExponentialH
require.Equal(t, numDataPoints, dps.Len())
for dpi := 0; dpi < numDataPoints; dpi++ {
dp := dps.At(dpi)
assert.Equal(
assert.InDelta(
t,
sampleDuration*float64(numCumulativeConsumptions),
dp.Sum(),
0.01,
"Should be a 11ms duration measurement, multiplied by the number of stateful accumulations.")
assert.Equal(t, uint64(numCumulativeConsumptions), dp.Count())
assert.Equal(t, []uint64{uint64(numCumulativeConsumptions)}, dp.Positive().BucketCounts().AsRaw())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ func TestAlertManagerExporterEventNameAttributes(t *testing.T) {
assert.Equal(t, "unittest-baz", attr.AsString())
attr, b = got[0].spanEvent.Attributes().Get("attr3")
assert.True(t, b)
assert.Equal(t, 5.14, attr.Double())
assert.InDelta(t, 5.14, attr.Double(), 0.01)
}

func TestAlertManagerExporterSeverity(t *testing.T) {
Expand Down
12 changes: 6 additions & 6 deletions exporter/awsemfexporter/datapoint_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1473,22 +1473,22 @@ func TestGetDataPoints(t *testing.T) {
dp := convertedDPS.NumberDataPointSlice.At(0)
switch dp.ValueType() {
case pmetric.NumberDataPointValueTypeDouble:
assert.Equal(t, 0.1, dp.DoubleValue())
assert.InDelta(t, 0.1, dp.DoubleValue(), 0.01)
case pmetric.NumberDataPointValueTypeInt:
assert.Equal(t, int64(1), dp.IntValue())
}
assert.Equal(t, tc.expectedAttributes, dp.Attributes().AsRaw())
case histogramDataPointSlice:
assert.Equal(t, 1, convertedDPS.Len())
dp := convertedDPS.HistogramDataPointSlice.At(0)
assert.Equal(t, 35.0, dp.Sum())
assert.InDelta(t, 35.0, dp.Sum(), 0.01)
assert.Equal(t, uint64(18), dp.Count())
assert.Equal(t, []float64{0, 10}, dp.ExplicitBounds().AsRaw())
assert.Equal(t, tc.expectedAttributes, dp.Attributes().AsRaw())
case exponentialHistogramDataPointSlice:
assert.Equal(t, 1, convertedDPS.Len())
dp := convertedDPS.ExponentialHistogramDataPointSlice.At(0)
assert.Equal(t, float64(0), dp.Sum())
assert.InDelta(t, float64(0), dp.Sum(), 0.01)
assert.Equal(t, uint64(4), dp.Count())
assert.Equal(t, []uint64{1, 0, 1}, dp.Positive().BucketCounts().AsRaw())
assert.Equal(t, []uint64{1, 0, 1}, dp.Negative().BucketCounts().AsRaw())
Expand All @@ -1499,11 +1499,11 @@ func TestGetDataPoints(t *testing.T) {
assert.Equal(t, expectedDPS.deltaMetricMetadata, convertedDPS.deltaMetricMetadata)
assert.Equal(t, 1, convertedDPS.Len())
dp := convertedDPS.SummaryDataPointSlice.At(0)
assert.Equal(t, 15.0, dp.Sum())
assert.InDelta(t, 15.0, dp.Sum(), 0.01)
assert.Equal(t, uint64(5), dp.Count())
assert.Equal(t, 2, dp.QuantileValues().Len())
assert.Equal(t, float64(1), dp.QuantileValues().At(0).Value())
assert.Equal(t, float64(5), dp.QuantileValues().At(1).Value())
assert.InDelta(t, float64(1), dp.QuantileValues().At(0).Value(), 0.01)
assert.InDelta(t, float64(5), dp.QuantileValues().At(1).Value(), 0.01)
assert.Equal(t, tc.expectedAttributes, dp.Attributes().AsRaw())
}
})
Expand Down
8 changes: 4 additions & 4 deletions exporter/awsxrayexporter/internal/translator/segment_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -472,7 +472,7 @@ func TestSpanWithAttributesDefaultNotIndexed(t *testing.T) {
assert.Equal(t, "val2", segment.Metadata["default"]["attr2@2"])
assert.Equal(t, "string", segment.Metadata["default"]["otel.resource.string.key"])
assert.Equal(t, int64(10), segment.Metadata["default"]["otel.resource.int.key"])
assert.Equal(t, 5.0, segment.Metadata["default"]["otel.resource.double.key"])
assert.InDelta(t, 5.0, segment.Metadata["default"]["otel.resource.double.key"], 0.01)
assert.Equal(t, true, segment.Metadata["default"]["otel.resource.bool.key"])
expectedMap := make(map[string]any)
expectedMap["key1"] = int64(1)
Expand Down Expand Up @@ -605,7 +605,7 @@ func TestResourceAttributesCanBeIndexed(t *testing.T) {
assert.Len(t, segment.Annotations, 4)
assert.Equal(t, "string", segment.Annotations["otel_resource_string_key"])
assert.Equal(t, int64(10), segment.Annotations["otel_resource_int_key"])
assert.Equal(t, 5.0, segment.Annotations["otel_resource_double_key"])
assert.InDelta(t, 5.0, segment.Annotations["otel_resource_double_key"], 0.01)
assert.Equal(t, true, segment.Annotations["otel_resource_bool_key"])
expectedMap := make(map[string]any)
expectedMap["key1"] = int64(1)
Expand Down Expand Up @@ -638,7 +638,7 @@ func TestResourceAttributesCanBeIndexedWithAllowDot(t *testing.T) {
assert.Len(t, segment.Annotations, 4)
assert.Equal(t, "string", segment.Annotations["otel.resource.string.key"])
assert.Equal(t, int64(10), segment.Annotations["otel.resource.int.key"])
assert.Equal(t, 5.0, segment.Annotations["otel.resource.double.key"])
assert.InDelta(t, 5.0, segment.Annotations["otel.resource.double.key"], 0.01)
assert.Equal(t, true, segment.Annotations["otel.resource.bool.key"])
expectedMap := make(map[string]any)
expectedMap["key1"] = int64(1)
Expand Down Expand Up @@ -984,7 +984,7 @@ func TestFilteredAttributesMetadata(t *testing.T) {
assert.Nil(t, segment.Metadata["default"]["null_value"])
assert.Equal(t, "value", segment.Metadata["default"]["string_value"])
assert.Equal(t, int64(123), segment.Metadata["default"]["int_value"])
assert.Equal(t, 456.78, segment.Metadata["default"]["float_value"])
assert.InDelta(t, 456.78, segment.Metadata["default"]["float_value"], 0.01)
assert.Equal(t, false, segment.Metadata["default"]["bool_value"])
assert.Equal(t, []any{int64(12), int64(34), int64(56)}, segment.Metadata["default"]["array_value"])
assert.Equal(t, map[string]any{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ func TestSpanLinkComplexAttributes(t *testing.T) {
assert.Equal(t, "myValue", segment.Links[0].Attributes["myKey1"])
assert.Equal(t, true, segment.Links[0].Attributes["myKey2"])
assert.Equal(t, int64(112233), segment.Links[0].Attributes["myKey3"])
assert.Equal(t, 3.1415, segment.Links[0].Attributes["myKey4"])
assert.InDelta(t, 3.1415, segment.Links[0].Attributes["myKey4"], 0.01)

assert.Equal(t, "apple", segment.Links[0].Attributes["myKey5"].([]any)[0])
assert.Equal(t, "pear", segment.Links[0].Attributes["myKey5"].([]any)[1])
Expand All @@ -193,8 +193,8 @@ func TestSpanLinkComplexAttributes(t *testing.T) {
assert.Equal(t, int64(5678), segment.Links[0].Attributes["myKey7"].([]any)[1])
assert.Equal(t, int64(9012), segment.Links[0].Attributes["myKey7"].([]any)[2])

assert.Equal(t, 2.718, segment.Links[0].Attributes["myKey8"].([]any)[0])
assert.Equal(t, 1.618, segment.Links[0].Attributes["myKey8"].([]any)[1])
assert.InDelta(t, 2.718, segment.Links[0].Attributes["myKey8"].([]any)[0], 0.01)
assert.InDelta(t, 1.618, segment.Links[0].Attributes["myKey8"].([]any)[1], 0.01)

jsonStr, _ := MakeSegmentDocumentString(span, resource, nil, false, nil, false)

Expand Down
2 changes: 1 addition & 1 deletion exporter/azuredataexplorerexporter/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -223,7 +223,7 @@ func TestCreateMetricsExporterE2E(t *testing.T) {
for i := 0; i < len(recs); i++ {
crec := recs[i]
assert.Equal(t, metricName, crec.MetricName)
assert.Equal(t, float64(metricValue), crec.MetricValue)
assert.InDelta(t, float64(metricValue), crec.MetricValue, 0.01)
assert.Equal(t, attrs, crec.MetricAttributes)
assert.Equal(t, metricDescription, crec.MetricDescription)
assert.Equal(t, metricUnit, crec.MetricUnit)
Expand Down
4 changes: 2 additions & 2 deletions exporter/azuredataexplorerexporter/metricsdata_to_adx_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ func Test_rawMetricsToAdxMetrics(t *testing.T) {
// Metric assertions
assert.Equal(t, expectedMetric.MetricName, actualMetrics[i].MetricName)
assert.Equal(t, expectedMetric.MetricType, actualMetrics[i].MetricType)
assert.Equalf(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, "Mismatch for value for test %s", tt.name)
assert.InDeltaf(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, 0.01, "Mismatch for value for test %s", tt.name)
assert.Equal(t, expectedMetric.MetricDescription, actualMetrics[i].MetricDescription)
assert.Equal(t, expectedMetric.MetricUnit, actualMetrics[i].MetricUnit)
assert.Equal(t, expectedMetric.MetricAttributes, actualMetrics[i].MetricAttributes)
Expand Down Expand Up @@ -556,7 +556,7 @@ func Test_mapToAdxMetric(t *testing.T) {
// Metric assertions
assert.Equal(t, expectedMetric.MetricName, actualMetrics[i].MetricName)
assert.Equal(t, expectedMetric.MetricType, actualMetrics[i].MetricType)
assert.Equalf(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, "Mismatch for value for test %s", tt.name)
assert.InDeltaf(t, expectedMetric.MetricValue, actualMetrics[i].MetricValue, 0.01, "Mismatch for value for test %s", tt.name)
assert.Equal(t, expectedMetric.MetricDescription, actualMetrics[i].MetricDescription)
assert.Equal(t, expectedMetric.MetricUnit, actualMetrics[i].MetricUnit)
assert.Equal(t, expectedMetric.MetricAttributes, actualMetrics[i].MetricAttributes)
Expand Down
22 changes: 11 additions & 11 deletions exporter/azuremonitorexporter/metricexporter_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ func TestDoubleGaugeEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, gaugeMetric)

assert.Equal(t, "Gauge", dataPoint.Name)
assert.Equal(t, float64(1), dataPoint.Value)
assert.InDelta(t, float64(1), dataPoint.Value, 0.01)
assert.Equal(t, 1, dataPoint.Count)
assert.Equal(t, contracts.Measurement, dataPoint.Kind)
}
Expand All @@ -46,7 +46,7 @@ func TestIntGaugeEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, gaugeMetric)

assert.Equal(t, "Gauge", dataPoint.Name)
assert.Equal(t, float64(1), dataPoint.Value)
assert.InDelta(t, float64(1), dataPoint.Value, 0.01)
assert.Equal(t, 1, dataPoint.Count)
assert.Equal(t, contracts.Measurement, dataPoint.Kind)
}
Expand All @@ -56,7 +56,7 @@ func TestDoubleSumEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, sumMetric)

assert.Equal(t, "Sum", dataPoint.Name)
assert.Equal(t, float64(2), dataPoint.Value)
assert.InDelta(t, float64(2), dataPoint.Value, 0.01)
assert.Equal(t, 1, dataPoint.Count)
assert.Equal(t, contracts.Measurement, dataPoint.Kind)
}
Expand All @@ -66,7 +66,7 @@ func TestIntSumEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, sumMetric)

assert.Equal(t, "Sum", dataPoint.Name)
assert.Equal(t, float64(2), dataPoint.Value)
assert.InDelta(t, float64(2), dataPoint.Value, 0.01)
assert.Equal(t, 1, dataPoint.Count)
assert.Equal(t, contracts.Measurement, dataPoint.Kind)
}
Expand All @@ -76,10 +76,10 @@ func TestHistogramEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, histogramMetric)

assert.Equal(t, "Histogram", dataPoint.Name)
assert.Equal(t, float64(3), dataPoint.Value)
assert.InDelta(t, float64(3), dataPoint.Value, 0.01)
assert.Equal(t, 3, dataPoint.Count)
assert.Equal(t, float64(0), dataPoint.Min)
assert.Equal(t, float64(2), dataPoint.Max)
assert.InDelta(t, float64(0), dataPoint.Min, 0.01)
assert.InDelta(t, float64(2), dataPoint.Max, 0.01)
assert.Equal(t, contracts.Aggregation, dataPoint.Kind)
}

Expand All @@ -88,10 +88,10 @@ func TestExponentialHistogramEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, exponentialHistogramMetric)

assert.Equal(t, "ExponentialHistogram", dataPoint.Name)
assert.Equal(t, float64(4), dataPoint.Value)
assert.InDelta(t, float64(4), dataPoint.Value, 0.01)
assert.Equal(t, 4, dataPoint.Count)
assert.Equal(t, float64(1), dataPoint.Min)
assert.Equal(t, float64(3), dataPoint.Max)
assert.InDelta(t, float64(1), dataPoint.Min, 0.01)
assert.InDelta(t, float64(3), dataPoint.Max, 0.01)
assert.Equal(t, contracts.Aggregation, dataPoint.Kind)
}

Expand All @@ -100,7 +100,7 @@ func TestSummaryEnvelopes(t *testing.T) {
dataPoint := getDataPoint(t, summaryMetric)

assert.Equal(t, "Summary", dataPoint.Name)
assert.Equal(t, float64(5), dataPoint.Value)
assert.InDelta(t, float64(5), dataPoint.Value, 0.01)
assert.Equal(t, 5, dataPoint.Count)
assert.Equal(t, contracts.Aggregation, dataPoint.Kind)
}
Expand Down
10 changes: 5 additions & 5 deletions exporter/clickhouseexporter/internal/metrics_model_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -206,19 +206,19 @@ func Test_convertValueAtQuantile(t *testing.T) {
func Test_getValue(t *testing.T) {
SetLogger(zaptest.NewLogger(t))
t.Run("set int64 value with NumberDataPointValueType", func(t *testing.T) {
require.Equal(t, 10.0, getValue(int64(10), 0, pmetric.NumberDataPointValueTypeInt))
require.InDelta(t, 10.0, getValue(int64(10), 0, pmetric.NumberDataPointValueTypeInt), 0.01)
})
t.Run("set float64 value with NumberDataPointValueType", func(t *testing.T) {
require.Equal(t, 20.0, getValue(0, 20.0, pmetric.NumberDataPointValueTypeDouble))
require.InDelta(t, 20.0, getValue(0, 20.0, pmetric.NumberDataPointValueTypeDouble), 0.01)
})
t.Run("set int64 value with ExemplarValueType", func(t *testing.T) {
require.Equal(t, 10.0, getValue(int64(10), 0, pmetric.ExemplarValueTypeInt))
require.InDelta(t, 10.0, getValue(int64(10), 0, pmetric.ExemplarValueTypeInt), 0.01)
})
t.Run("set float64 value with ExemplarValueType", func(t *testing.T) {
require.Equal(t, 20.0, getValue(0, 20.0, pmetric.ExemplarValueTypeDouble))
require.InDelta(t, 20.0, getValue(0, 20.0, pmetric.ExemplarValueTypeDouble), 0.01)
})
t.Run("set a unsupport dataType", func(t *testing.T) {
require.Equal(t, 0.0, getValue(int64(10), 0, pmetric.MetricTypeHistogram))
require.InDelta(t, 0.0, getValue(int64(10), 0, pmetric.MetricTypeHistogram), 0.01)
})
}

Expand Down
24 changes: 12 additions & 12 deletions exporter/datadogexporter/integrationtest/integration_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -366,20 +366,20 @@ func TestIntegrationComputeTopLevelBySpanKind(t *testing.T) {
for _, span := range spans {
switch {
case span.Meta["span.kind"] == apitrace.SpanKindInternal.String():
assert.EqualValues(t, 0, span.Metrics["_top_level"])
assert.EqualValues(t, 0, span.Metrics["_dd.measured"])
assert.InDelta(t, 0.0, span.Metrics["_top_level"], 0.01)
assert.InDelta(t, 0.0, span.Metrics["_dd.measured"], 0.01)
case span.Meta["span.kind"] == apitrace.SpanKindServer.String():
assert.EqualValues(t, 1, span.Metrics["_top_level"])
assert.EqualValues(t, 0, span.Metrics["_dd.measured"])
assert.InDelta(t, 1.0, span.Metrics["_top_level"], 0.01)
assert.InDelta(t, 0.0, span.Metrics["_dd.measured"], 0.01)
case span.Meta["span.kind"] == apitrace.SpanKindClient.String():
assert.EqualValues(t, 0, span.Metrics["_top_level"])
assert.EqualValues(t, 1, span.Metrics["_dd.measured"])
assert.InDelta(t, 0.0, span.Metrics["_top_level"], 0.01)
assert.InDelta(t, 1.0, span.Metrics["_dd.measured"], 0.01)
case span.Meta["span.kind"] == apitrace.SpanKindProducer.String():
assert.EqualValues(t, 0, span.Metrics["_top_level"])
assert.EqualValues(t, 1, span.Metrics["_dd.measured"])
assert.InDelta(t, 0.0, span.Metrics["_top_level"], 0.01)
assert.InDelta(t, 1, span.Metrics["_dd.measured"], 0.01)
case span.Meta["span.kind"] == apitrace.SpanKindConsumer.String():
assert.EqualValues(t, 1, span.Metrics["_top_level"])
assert.EqualValues(t, 0, span.Metrics["_dd.measured"])
assert.InDelta(t, 1.0, span.Metrics["_top_level"], 0.01)
assert.InDelta(t, 0.0, span.Metrics["_dd.measured"], 0.01)
}
}
}
Expand Down Expand Up @@ -508,12 +508,12 @@ func TestIntegrationLogs(t *testing.T) {
if s.Metric == "otelcol_receiver_accepted_log_records" {
numAcceptedLogRecords++
assert.Len(t, s.Points, 1)
assert.Equal(t, 5.0, s.Points[0].Value)
assert.InDelta(t, 5.0, s.Points[0].Value, 0.01)
}
if s.Metric == "otelcol_exporter_sent_log_records" {
numSentLogRecords++
assert.Len(t, s.Points, 1)
assert.Equal(t, 5.0, s.Points[0].Value)
assert.InDelta(t, 5.0, s.Points[0].Value, 0.01)
}
}
assert.Equal(t, 2, numAcceptedLogRecords)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,9 +20,9 @@ func TestNewZorkianMetric(t *testing.T) {

assert.Equal(t, "test.metric", *metric.Metric)
// Assert timestamp conversion from uint64 ns to float64 s
assert.Equal(t, 1.0, *metric.Points[0][0])
assert.InDelta(t, 1.0, *metric.Points[0][0], 0.01)
// Assert value
assert.Equal(t, 2.0, *metric.Points[0][1])
assert.InDelta(t, 2.0, *metric.Points[0][1], 0.01)
// Assert tags
assert.Equal(t, []string{"tag:value"}, metric.Tags)
}
Expand Down Expand Up @@ -53,9 +53,9 @@ func TestDefaultZorkianMetrics(t *testing.T) {
// Assert metrics list length (should be 1)
assert.Len(t, ms, 1)
// Assert timestamp
assert.Equal(t, 2.0, *ms[0].Points[0][0])
assert.InDelta(t, 2.0, *ms[0].Points[0][0], 0.01)
// Assert value (should always be 1.0)
assert.Equal(t, 1.0, *ms[0].Points[0][1])
assert.InDelta(t, 1.0, *ms[0].Points[0][1], 0.01)
// Assert hostname tag is set
assert.Equal(t, "test-host", *ms[0].Host)
// Assert no other tags are set
Expand Down
6 changes: 3 additions & 3 deletions exporter/datadogexporter/internal/metrics/series_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ func TestNewMetricSeries(t *testing.T) {
// Assert timestamp conversion from uint64 ns to int64 s
assert.Equal(t, int64(1), *metric.Points[0].Timestamp)
// Assert value
assert.Equal(t, 2.0, *metric.Points[0].Value)
assert.InDelta(t, 2.0, *metric.Points[0].Value, 0.01)
// Assert tags
assert.Equal(t, []string{"tag:value"}, metric.Tags)
}
Expand Down Expand Up @@ -55,7 +55,7 @@ func TestDefaultMetrics(t *testing.T) {
// Assert timestamp
assert.Equal(t, int64(2), *ms[0].Points[0].Timestamp)
// Assert value (should always be 1.0)
assert.Equal(t, 1.0, *ms[0].Points[0].Value)
assert.InDelta(t, 1.0, *ms[0].Points[0].Value, 0.01)
// Assert hostname tag is set
assert.Equal(t, "test-host", *ms[0].Resources[0].Name)
// Assert no other tags are set
Expand All @@ -77,7 +77,7 @@ func TestDefaultMetricsWithRuntimeMetrics(t *testing.T) {
// Assert timestamp
assert.Equal(t, int64(2), *ms[0].Points[0].Timestamp)
// Assert value (should always be 1.0)
assert.Equal(t, 1.0, *ms[0].Points[0].Value)
assert.InDelta(t, 1.0, *ms[0].Points[0].Value, 0.01)
// Assert hostname tag is set
assert.Equal(t, "test-host", *ms[0].Resources[0].Name)
// Assert no other tags are set
Expand Down
Loading

0 comments on commit e1785be

Please sign in to comment.