Allow graphite parser to create Inf and NaN values (#6420)

This commit is contained in:
Daniel Nelson
2019-09-19 20:03:10 -07:00
committed by GitHub
parent e553341879
commit 8d96dd71c7
4 changed files with 41 additions and 30 deletions

View File

@@ -129,7 +129,7 @@ func IgnoreTime() cmp.Option {
}
// MetricEqual returns true if the metrics are equal.
func MetricEqual(expected, actual telegraf.Metric) bool {
func MetricEqual(expected, actual telegraf.Metric, opts ...cmp.Option) bool {
var lhs, rhs *metricDiff
if expected != nil {
lhs = newMetricDiff(expected)
@@ -138,7 +138,8 @@ func MetricEqual(expected, actual telegraf.Metric) bool {
rhs = newMetricDiff(actual)
}
return cmp.Equal(lhs, rhs)
opts = append(opts, cmpopts.EquateNaNs())
return cmp.Equal(lhs, rhs, opts...)
}
// RequireMetricEqual halts the test with an error if the metrics are not
@@ -154,6 +155,7 @@ func RequireMetricEqual(t *testing.T, expected, actual telegraf.Metric, opts ...
rhs = newMetricDiff(actual)
}
opts = append(opts, cmpopts.EquateNaNs())
if diff := cmp.Diff(lhs, rhs, opts...); diff != "" {
t.Fatalf("telegraf.Metric\n--- expected\n+++ actual\n%s", diff)
}
@@ -172,6 +174,8 @@ func RequireMetricsEqual(t *testing.T, expected, actual []telegraf.Metric, opts
for _, m := range actual {
rhs = append(rhs, newMetricDiff(m))
}
opts = append(opts, cmpopts.EquateNaNs())
if diff := cmp.Diff(lhs, rhs, opts...); diff != "" {
t.Fatalf("[]telegraf.Metric\n--- expected\n+++ actual\n%s", diff)
}