1
0
mirror of https://github.com/mainflux/mainflux.git synced 2025-05-04 22:17:59 +08:00
Dejan Mijic c966a7802d
Integrate manager service
Setup top-level glide dependencies file. Migrated all of the manager
service code into this repository. Fixed docker build procedure.
Extracted executable to the top-level.

Signed-off-by: Dejan Mijic <dejan@mainflux.com>
2017-09-23 01:03:27 +02:00

34 lines
732 B
Go

package metrics_test
import (
"math"
"testing"
"time"
"github.com/go-kit/kit/metrics"
"github.com/go-kit/kit/metrics/generic"
)
func TestTimerFast(t *testing.T) {
h := generic.NewSimpleHistogram()
metrics.NewTimer(h).ObserveDuration()
tolerance := 0.050
if want, have := 0.000, h.ApproximateMovingAverage(); math.Abs(want-have) > tolerance {
t.Errorf("want %.3f, have %.3f", want, have)
}
}
func TestTimerSlow(t *testing.T) {
h := generic.NewSimpleHistogram()
timer := metrics.NewTimer(h)
time.Sleep(250 * time.Millisecond)
timer.ObserveDuration()
tolerance := 0.050
if want, have := 0.250, h.ApproximateMovingAverage(); math.Abs(want-have) > tolerance {
t.Errorf("want %.3f, have %.3f", want, have)
}
}