prusa-connect-exporter/main_test.go

25 lines
396 B
Go
Raw Normal View History

package main
import (
"testing"
"time"
)
func TestParseDuration(t *testing.T) {
d := parseDuration(" 45s")
if d != (45 * time.Second) {
t.Log(d)
t.Fail()
}
d = parseDuration(" 10m 45s")
if d != (45*time.Second)+(10*time.Minute) {
t.Log(d)
t.Fail()
}
d = parseDuration(" 12h 10m 45s")
if d != (12*time.Hour)+(45*time.Second)+(10*time.Minute) {
t.Log(d)
t.Fail()
}
}