metrics: fix issues reported by staticcheck (#20365)

This commit is contained in:
Guillaume Ballet
2019-11-22 16:04:35 +01:00
committed by Felix Lange
parent dd21f079e8
commit 58f2ce8671
15 changed files with 109 additions and 105 deletions

View File

@ -14,7 +14,7 @@ func TestCounterClear(t *testing.T) {
c := NewCounter()
c.Inc(1)
c.Clear()
if count := c.Count(); 0 != count {
if count := c.Count(); count != 0 {
t.Errorf("c.Count(): 0 != %v\n", count)
}
}
@ -22,7 +22,7 @@ func TestCounterClear(t *testing.T) {
func TestCounterDec1(t *testing.T) {
c := NewCounter()
c.Dec(1)
if count := c.Count(); -1 != count {
if count := c.Count(); count != -1 {
t.Errorf("c.Count(): -1 != %v\n", count)
}
}
@ -30,7 +30,7 @@ func TestCounterDec1(t *testing.T) {
func TestCounterDec2(t *testing.T) {
c := NewCounter()
c.Dec(2)
if count := c.Count(); -2 != count {
if count := c.Count(); count != -2 {
t.Errorf("c.Count(): -2 != %v\n", count)
}
}
@ -38,7 +38,7 @@ func TestCounterDec2(t *testing.T) {
func TestCounterInc1(t *testing.T) {
c := NewCounter()
c.Inc(1)
if count := c.Count(); 1 != count {
if count := c.Count(); count != 1 {
t.Errorf("c.Count(): 1 != %v\n", count)
}
}
@ -46,7 +46,7 @@ func TestCounterInc1(t *testing.T) {
func TestCounterInc2(t *testing.T) {
c := NewCounter()
c.Inc(2)
if count := c.Count(); 2 != count {
if count := c.Count(); count != 2 {
t.Errorf("c.Count(): 2 != %v\n", count)
}
}
@ -56,14 +56,14 @@ func TestCounterSnapshot(t *testing.T) {
c.Inc(1)
snapshot := c.Snapshot()
c.Inc(1)
if count := snapshot.Count(); 1 != count {
if count := snapshot.Count(); count != 1 {
t.Errorf("c.Count(): 1 != %v\n", count)
}
}
func TestCounterZero(t *testing.T) {
c := NewCounter()
if count := c.Count(); 0 != count {
if count := c.Count(); count != 0 {
t.Errorf("c.Count(): 0 != %v\n", count)
}
}
@ -71,7 +71,7 @@ func TestCounterZero(t *testing.T) {
func TestGetOrRegisterCounter(t *testing.T) {
r := NewRegistry()
NewRegisteredCounter("foo", r).Inc(47)
if c := GetOrRegisterCounter("foo", r); 47 != c.Count() {
if c := GetOrRegisterCounter("foo", r); c.Count() != 47 {
t.Fatal(c)
}
}