Skip to content

Commit 916659f

Browse files
committed
fix tests warning about string(int) type conversions
See golang/go#32479 Signed-off-by: Mitsuo Heijo <[email protected]>
1 parent b0cdec2 commit 916659f

File tree

3 files changed

+6
-6
lines changed

3 files changed

+6
-6
lines changed

prometheus/gauge_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,15 +139,15 @@ func TestGaugeVecConcurrency(t *testing.T) {
139139
start.Wait()
140140
for i, v := range vals {
141141
sStreams[pick[i]] <- v
142-
gge.WithLabelValues(string('A' + pick[i])).Add(v)
142+
gge.WithLabelValues(string('A' + rune(pick[i]))).Add(v)
143143
}
144144
end.Done()
145145
}(vals)
146146
}
147147
start.Done()
148148

149149
for i := range sStreams {
150-
if expected, got := <-results[i], math.Float64frombits(gge.WithLabelValues(string('A'+i)).(*gauge).valBits); math.Abs(expected-got) > 0.000001 {
150+
if expected, got := <-results[i], math.Float64frombits(gge.WithLabelValues(string('A'+rune(i))).(*gauge).valBits); math.Abs(expected-got) > 0.000001 {
151151
t.Fatalf("expected approx. %f, got %f", expected, got)
152152
return false
153153
}

prometheus/histogram_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -279,7 +279,7 @@ func TestHistogramVecConcurrency(t *testing.T) {
279279
go func(vals []float64) {
280280
start.Wait()
281281
for i, v := range vals {
282-
his.WithLabelValues(string('A' + picks[i])).Observe(v)
282+
his.WithLabelValues(string('A' + rune(picks[i]))).Observe(v)
283283
}
284284
end.Done()
285285
}(vals)
@@ -292,7 +292,7 @@ func TestHistogramVecConcurrency(t *testing.T) {
292292

293293
for i := 0; i < vecLength; i++ {
294294
m := &dto.Metric{}
295-
s := his.WithLabelValues(string('A' + i))
295+
s := his.WithLabelValues(string('A' + rune(i)))
296296
s.(Histogram).Write(m)
297297

298298
if got, want := len(m.Histogram.Bucket), len(testBuckets)-1; got != want {

prometheus/summary_test.go

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -321,7 +321,7 @@ func TestSummaryVecConcurrency(t *testing.T) {
321321
go func(vals []float64) {
322322
start.Wait()
323323
for i, v := range vals {
324-
sum.WithLabelValues(string('A' + picks[i])).Observe(v)
324+
sum.WithLabelValues(string('A' + rune(picks[i]))).Observe(v)
325325
}
326326
end.Done()
327327
}(vals)
@@ -334,7 +334,7 @@ func TestSummaryVecConcurrency(t *testing.T) {
334334

335335
for i := 0; i < vecLength; i++ {
336336
m := &dto.Metric{}
337-
s := sum.WithLabelValues(string('A' + i))
337+
s := sum.WithLabelValues(string('A' + rune(i)))
338338
s.(Summary).Write(m)
339339
if got, want := int(*m.Summary.SampleCount), len(allVars[i]); got != want {
340340
t.Errorf("got sample count %d for label %c, want %d", got, 'A'+i, want)

0 commit comments

Comments
 (0)