Merge pull request #779 from johejo/fix_tests_string_type_conversions

fix tests warning about string(int) type conversions
This commit is contained in:
Björn Rabenstein 2020-07-06 15:16:39 +02:00 committed by GitHub
commit d3accfda21
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with 6 additions and 6 deletions

View File

@ -139,7 +139,7 @@ func TestGaugeVecConcurrency(t *testing.T) {
start.Wait() start.Wait()
for i, v := range vals { for i, v := range vals {
sStreams[pick[i]] <- v sStreams[pick[i]] <- v
gge.WithLabelValues(string('A' + pick[i])).Add(v) gge.WithLabelValues(string('A' + rune(pick[i]))).Add(v)
} }
end.Done() end.Done()
}(vals) }(vals)
@ -147,7 +147,7 @@ func TestGaugeVecConcurrency(t *testing.T) {
start.Done() start.Done()
for i := range sStreams { 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) t.Fatalf("expected approx. %f, got %f", expected, got)
return false return false
} }

View File

@ -279,7 +279,7 @@ func TestHistogramVecConcurrency(t *testing.T) {
go func(vals []float64) { go func(vals []float64) {
start.Wait() start.Wait()
for i, v := range vals { for i, v := range vals {
his.WithLabelValues(string('A' + picks[i])).Observe(v) his.WithLabelValues(string('A' + rune(picks[i]))).Observe(v)
} }
end.Done() end.Done()
}(vals) }(vals)
@ -292,7 +292,7 @@ func TestHistogramVecConcurrency(t *testing.T) {
for i := 0; i < vecLength; i++ { for i := 0; i < vecLength; i++ {
m := &dto.Metric{} m := &dto.Metric{}
s := his.WithLabelValues(string('A' + i)) s := his.WithLabelValues(string('A' + rune(i)))
s.(Histogram).Write(m) s.(Histogram).Write(m)
if got, want := len(m.Histogram.Bucket), len(testBuckets)-1; got != want { 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) { go func(vals []float64) {
start.Wait() start.Wait()
for i, v := range vals { for i, v := range vals {
sum.WithLabelValues(string('A' + picks[i])).Observe(v) sum.WithLabelValues(string('A' + rune(picks[i]))).Observe(v)
} }
end.Done() end.Done()
}(vals) }(vals)
@ -334,7 +334,7 @@ func TestSummaryVecConcurrency(t *testing.T) {
for i := 0; i < vecLength; i++ { for i := 0; i < vecLength; i++ {
m := &dto.Metric{} m := &dto.Metric{}
s := sum.WithLabelValues(string('A' + i)) s := sum.WithLabelValues(string('A' + rune(i)))
s.(Summary).Write(m) s.(Summary).Write(m)
if got, want := int(*m.Summary.SampleCount), len(allVars[i]); got != want { 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) t.Errorf("got sample count %d for label %c, want %d", got, 'A'+i, want)