uptime metric reporting (#32)

This commit is contained in:
Steve Brunton
2019-01-02 16:16:09 -05:00
committed by GitHub
parent d4288aed19
commit aee1517c10
5 changed files with 108 additions and 10 deletions

View File

@@ -0,0 +1,27 @@
package collector
import (
"testing"
)
func TestParseUptime(t *testing.T) {
uptimes := []struct {
u string
v float64
}{
{"3d3h42m53s", 272573},
{"15w3d3h42m53s", 9344573},
{"42m53s", 2573},
}
for _, uptime := range uptimes {
seconds, err := parseUptime(uptime.u)
if err != nil {
t.Error(err)
}
if seconds != uptime.v {
t.Errorf("seconds : %f != v : %f\n", seconds, uptime.v)
}
}
}