|
|
@@ -1,6 +1,9 @@
|
|
|
package metrics
|
|
|
|
|
|
-import "testing"
|
|
|
+import (
|
|
|
+ "testing"
|
|
|
+ "time"
|
|
|
+)
|
|
|
|
|
|
func TestMeterZero(t *testing.T) {
|
|
|
m := NewMeter()
|
|
|
@@ -16,3 +19,18 @@ func TestMeterNonzero(t *testing.T) {
|
|
|
t.Errorf("m.Count(): 3 != %v\n", count)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+func TestMeterDecay(t *testing.T) {
|
|
|
+ m := &StandardMeter{
|
|
|
+ make(chan int64),
|
|
|
+ make(chan meterV),
|
|
|
+ time.NewTicker(1),
|
|
|
+ }
|
|
|
+ go m.arbiter()
|
|
|
+ m.Mark(1)
|
|
|
+ rateMean := m.RateMean()
|
|
|
+ time.Sleep(1)
|
|
|
+ if m.RateMean() >= rateMean {
|
|
|
+ t.Error("m.RateMean() didn't decrease")
|
|
|
+ }
|
|
|
+}
|