|
|
@@ -84,6 +84,27 @@ func TestMacroEngine(t *testing.T) {
|
|
|
So(sql, ShouldEqual, fmt.Sprintf("select time >= %d AND time <= %d", from.Unix(), to.Unix()))
|
|
|
})
|
|
|
|
|
|
+ Convey("interpolate __unixEpochNanoFilter function", func() {
|
|
|
+ sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochNanoFilter(time)")
|
|
|
+ So(err, ShouldBeNil)
|
|
|
+
|
|
|
+ So(sql, ShouldEqual, fmt.Sprintf("select time >= %d AND time <= %d", from.UnixNano(), to.UnixNano()))
|
|
|
+ })
|
|
|
+
|
|
|
+ Convey("interpolate __unixEpochNanoFrom function", func() {
|
|
|
+ sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochNanoFrom()")
|
|
|
+ So(err, ShouldBeNil)
|
|
|
+
|
|
|
+ So(sql, ShouldEqual, fmt.Sprintf("select %d", from.UnixNano()))
|
|
|
+ })
|
|
|
+
|
|
|
+ Convey("interpolate __unixEpochNanoTo function", func() {
|
|
|
+ sql, err := engine.Interpolate(query, timeRange, "select $__unixEpochNanoTo()")
|
|
|
+ So(err, ShouldBeNil)
|
|
|
+
|
|
|
+ So(sql, ShouldEqual, fmt.Sprintf("select %d", to.UnixNano()))
|
|
|
+ })
|
|
|
+
|
|
|
Convey("interpolate __unixEpochGroup function", func() {
|
|
|
|
|
|
sql, err := engine.Interpolate(query, timeRange, "SELECT $__unixEpochGroup(time_column,'5m')")
|