|
|
@@ -20,25 +20,30 @@ func TestAlertRuleModel(t *testing.T) {
|
|
|
})
|
|
|
|
|
|
Convey("Can parse seconds", func() {
|
|
|
- seconds := getTimeDurationStringToSeconds("10s")
|
|
|
+ seconds, _ := getTimeDurationStringToSeconds("10s")
|
|
|
So(seconds, ShouldEqual, 10)
|
|
|
})
|
|
|
|
|
|
Convey("Can parse minutes", func() {
|
|
|
- seconds := getTimeDurationStringToSeconds("10m")
|
|
|
+ seconds, _ := getTimeDurationStringToSeconds("10m")
|
|
|
So(seconds, ShouldEqual, 600)
|
|
|
})
|
|
|
|
|
|
Convey("Can parse hours", func() {
|
|
|
- seconds := getTimeDurationStringToSeconds("1h")
|
|
|
+ seconds, _ := getTimeDurationStringToSeconds("1h")
|
|
|
So(seconds, ShouldEqual, 3600)
|
|
|
})
|
|
|
|
|
|
Convey("defaults to seconds", func() {
|
|
|
- seconds := getTimeDurationStringToSeconds("1o")
|
|
|
+ seconds, _ := getTimeDurationStringToSeconds("1o")
|
|
|
So(seconds, ShouldEqual, 1)
|
|
|
})
|
|
|
|
|
|
+ Convey("should return err for empty string", func() {
|
|
|
+ _, err := getTimeDurationStringToSeconds("")
|
|
|
+ So(err, ShouldNotBeNil)
|
|
|
+ })
|
|
|
+
|
|
|
Convey("can construct alert rule model", func() {
|
|
|
json := `
|
|
|
{
|