fix tests warning about string(int) type conversions

See https://github.com/golang/go/issues/32479

Signed-off-by: Mitsuo Heijo <mitsuo.heijo@gmail.com>
This commit is contained in:
Mitsuo Heijo 2020-07-06 09:58:12 +09:00
parent b0cdec211b
commit 916659fee0
3 changed files with 6 additions and 6 deletions

View File

@ -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
}

View File

@ -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 {

View File

@ -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)