Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
N
nexpie-grafana-theme
Overview
Overview
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Registry
Registry
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Kornkitt Poolsup
nexpie-grafana-theme
Commits
2fb25d8f
Commit
2fb25d8f
authored
Aug 08, 2017
by
Daniel Lee
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
mysqlds: add tests for new macros
parent
a8ac2150
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
55 additions
and
0 deletions
+55
-0
pkg/tsdb/mysql/macros_test.go
+55
-0
No files found.
pkg/tsdb/mysql/macros_test.go
View file @
2fb25d8f
...
...
@@ -39,5 +39,60 @@ func TestMacroEngine(t *testing.T) {
So
(
sql
,
ShouldEqual
,
"WHERE time_column >= FROM_UNIXTIME(18446744066914186738) AND time_column <= FROM_UNIXTIME(18446744066914187038)"
)
})
Convey
(
"interpolate __timeFrom function"
,
func
()
{
engine
:=
&
MySqlMacroEngine
{
TimeRange
:
&
tsdb
.
TimeRange
{
From
:
"5m"
,
To
:
"now"
},
}
sql
,
err
:=
engine
.
Interpolate
(
"select $__timeFrom(time_column)"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"select FROM_UNIXTIME(18446744066914186738)"
)
})
Convey
(
"interpolate __timeTo function"
,
func
()
{
engine
:=
&
MySqlMacroEngine
{
TimeRange
:
&
tsdb
.
TimeRange
{
From
:
"5m"
,
To
:
"now"
},
}
sql
,
err
:=
engine
.
Interpolate
(
"select $__timeTo(time_column)"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"select FROM_UNIXTIME(18446744066914187038)"
)
})
Convey
(
"interpolate __unixEpochFilter function"
,
func
()
{
engine
:=
&
MySqlMacroEngine
{
TimeRange
:
&
tsdb
.
TimeRange
{
From
:
"5m"
,
To
:
"now"
},
}
sql
,
err
:=
engine
.
Interpolate
(
"select $__unixEpochFilter(18446744066914186738)"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"select 18446744066914186738 >= 18446744066914186738 AND 18446744066914186738 <= 18446744066914187038"
)
})
Convey
(
"interpolate __unixEpochFrom function"
,
func
()
{
engine
:=
&
MySqlMacroEngine
{
TimeRange
:
&
tsdb
.
TimeRange
{
From
:
"5m"
,
To
:
"now"
},
}
sql
,
err
:=
engine
.
Interpolate
(
"select $__unixEpochFrom()"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"select 18446744066914186738"
)
})
Convey
(
"interpolate __unixEpochTo function"
,
func
()
{
engine
:=
&
MySqlMacroEngine
{
TimeRange
:
&
tsdb
.
TimeRange
{
From
:
"5m"
,
To
:
"now"
},
}
sql
,
err
:=
engine
.
Interpolate
(
"select $__unixEpochTo()"
)
So
(
err
,
ShouldBeNil
)
So
(
sql
,
ShouldEqual
,
"select 18446744066914187038"
)
})
})
}
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment