|
@@ -37,10 +37,14 @@ func TestTimeGrain(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
- Convey("create ISO 8601 Duration from Grafana interval", func() {
|
|
|
|
|
|
|
+ Convey("create ISO 8601 Duration from Grafana interval in milliseconds", func() {
|
|
|
Convey("and interval is less than a minute", func() {
|
|
Convey("and interval is less than a minute", func() {
|
|
|
- durationMS, _ := tgc.createISO8601DurationFromInterval("100ms")
|
|
|
|
|
- durationS, _ := tgc.createISO8601DurationFromInterval("59s")
|
|
|
|
|
|
|
+ durationMS, err := tgc.createISO8601DurationFromIntervalMS(100)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+
|
|
|
|
|
+ durationS, err := tgc.createISO8601DurationFromIntervalMS(59999)
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+
|
|
|
Convey("should be rounded up to a minute as is the minimum interval for Azure Monitor", func() {
|
|
Convey("should be rounded up to a minute as is the minimum interval for Azure Monitor", func() {
|
|
|
So(durationMS, ShouldEqual, "PT1M")
|
|
So(durationMS, ShouldEqual, "PT1M")
|
|
|
So(durationS, ShouldEqual, "PT1M")
|
|
So(durationS, ShouldEqual, "PT1M")
|
|
@@ -48,8 +52,15 @@ func TestTimeGrain(t *testing.T) {
|
|
|
})
|
|
})
|
|
|
|
|
|
|
|
Convey("and interval is more than a minute", func() {
|
|
Convey("and interval is more than a minute", func() {
|
|
|
- durationM, _ := tgc.createISO8601DurationFromInterval("10m")
|
|
|
|
|
- durationD, _ := tgc.createISO8601DurationFromInterval("2d")
|
|
|
|
|
|
|
+ intervals := map[string]int64{
|
|
|
|
|
+ "10m": 600000,
|
|
|
|
|
+ "2d": 172800000,
|
|
|
|
|
+ }
|
|
|
|
|
+ durationM, err := tgc.createISO8601DurationFromIntervalMS(intervals["10m"])
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+ durationD, err := tgc.createISO8601DurationFromIntervalMS(intervals["2d"])
|
|
|
|
|
+ So(err, ShouldBeNil)
|
|
|
|
|
+
|
|
|
Convey("should be rounded up to a minute as is the minimum interval for Azure Monitor", func() {
|
|
Convey("should be rounded up to a minute as is the minimum interval for Azure Monitor", func() {
|
|
|
So(durationM, ShouldEqual, "PT10M")
|
|
So(durationM, ShouldEqual, "PT10M")
|
|
|
So(durationD, ShouldEqual, "P2D")
|
|
So(durationD, ShouldEqual, "P2D")
|