From 06444ed5c0411bc64e473e81533a2da5bc0df87c Mon Sep 17 00:00:00 2001 From: Dave Rawks Date: Tue, 15 Aug 2017 08:51:13 -0700 Subject: [PATCH] Minor fix-ups per PR discussion * Removed extraneous newline * Reformatted/ordered imports * Used hash function to derive index of `Elements` instead of hardcoding hash result --- exporter_test.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/exporter_test.go b/exporter_test.go index d37f0ba..3d81f99 100644 --- a/exporter_test.go +++ b/exporter_test.go @@ -15,10 +15,11 @@ package main import ( "fmt" - "github.com/prometheus/client_golang/prometheus" "net" "testing" "time" + + "github.com/prometheus/client_golang/prometheus" ) // TestNegativeCounter validates when we send a negative @@ -83,14 +84,14 @@ type MockHistogram struct { func (h *MockHistogram) Observe(n float64) { h.value = n - } func TestHistogramUnits(t *testing.T) { events := make(chan Events, 1) + name := "foo" c := Events{ &TimerEvent{ - metricName: "foo", + metricName: name, value: 300, }, } @@ -104,7 +105,8 @@ func TestHistogramUnits(t *testing.T) { close(events) }() mock := &MockHistogram{} - ex.Histograms.Elements[7787632782521330630] = mock + key := hashNameAndLabels(name+"_timer", nil) + ex.Histograms.Elements[key] = mock ex.Listen(events) if mock.value == 300 { t.Fatalf("Histogram observations not scaled into Seconds")