From 916659fee0fe8ca403ce46f56ffce728666f702e Mon Sep 17 00:00:00 2001 From: Mitsuo Heijo Date: Mon, 6 Jul 2020 09:58:12 +0900 Subject: [PATCH] fix tests warning about string(int) type conversions See https://github.com/golang/go/issues/32479 Signed-off-by: Mitsuo Heijo --- prometheus/gauge_test.go | 4 ++-- prometheus/histogram_test.go | 4 ++-- prometheus/summary_test.go | 4 ++-- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/prometheus/gauge_test.go b/prometheus/gauge_test.go index a2e3c14..b70da7d 100644 --- a/prometheus/gauge_test.go +++ b/prometheus/gauge_test.go @@ -139,7 +139,7 @@ func TestGaugeVecConcurrency(t *testing.T) { start.Wait() for i, v := range vals { sStreams[pick[i]] <- v - gge.WithLabelValues(string('A' + pick[i])).Add(v) + gge.WithLabelValues(string('A' + rune(pick[i]))).Add(v) } end.Done() }(vals) @@ -147,7 +147,7 @@ func TestGaugeVecConcurrency(t *testing.T) { start.Done() for i := range sStreams { - if expected, got := <-results[i], math.Float64frombits(gge.WithLabelValues(string('A'+i)).(*gauge).valBits); math.Abs(expected-got) > 0.000001 { + if expected, got := <-results[i], math.Float64frombits(gge.WithLabelValues(string('A'+rune(i))).(*gauge).valBits); math.Abs(expected-got) > 0.000001 { t.Fatalf("expected approx. %f, got %f", expected, got) return false } diff --git a/prometheus/histogram_test.go b/prometheus/histogram_test.go index 0b4826c..e779c1a 100644 --- a/prometheus/histogram_test.go +++ b/prometheus/histogram_test.go @@ -279,7 +279,7 @@ func TestHistogramVecConcurrency(t *testing.T) { go func(vals []float64) { start.Wait() for i, v := range vals { - his.WithLabelValues(string('A' + picks[i])).Observe(v) + his.WithLabelValues(string('A' + rune(picks[i]))).Observe(v) } end.Done() }(vals) @@ -292,7 +292,7 @@ func TestHistogramVecConcurrency(t *testing.T) { for i := 0; i < vecLength; i++ { m := &dto.Metric{} - s := his.WithLabelValues(string('A' + i)) + s := his.WithLabelValues(string('A' + rune(i))) s.(Histogram).Write(m) if got, want := len(m.Histogram.Bucket), len(testBuckets)-1; got != want { diff --git a/prometheus/summary_test.go b/prometheus/summary_test.go index 43b8396..eff733a 100644 --- a/prometheus/summary_test.go +++ b/prometheus/summary_test.go @@ -321,7 +321,7 @@ func TestSummaryVecConcurrency(t *testing.T) { go func(vals []float64) { start.Wait() for i, v := range vals { - sum.WithLabelValues(string('A' + picks[i])).Observe(v) + sum.WithLabelValues(string('A' + rune(picks[i]))).Observe(v) } end.Done() }(vals) @@ -334,7 +334,7 @@ func TestSummaryVecConcurrency(t *testing.T) { for i := 0; i < vecLength; i++ { m := &dto.Metric{} - s := sum.WithLabelValues(string('A' + i)) + s := sum.WithLabelValues(string('A' + rune(i))) s.(Summary).Write(m) if got, want := int(*m.Summary.SampleCount), len(allVars[i]); got != want { t.Errorf("got sample count %d for label %c, want %d", got, 'A'+i, want)