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
5c0094fe
Unverified
Commit
5c0094fe
authored
Dec 21, 2020
by
Emil Hessman
Committed by
GitHub
Dec 21, 2020
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Chore: Rewrite influxdb query parser test to standard library (#29940)
parent
4f0c9411
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
23 additions
and
25 deletions
+23
-25
pkg/tsdb/influxdb/model_parser_test.go
+23
-25
No files found.
pkg/tsdb/influxdb/model_parser_test.go
View file @
5c0094fe
...
...
@@ -6,17 +6,16 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey
"
"github.com/stretchr/testify/require
"
)
func
TestInfluxdbQueryParser
(
t
*
testing
.
T
)
{
Convey
(
"Influxdb query parser"
,
t
,
func
()
{
func
TestInfluxdbQueryParser_Parse
(
t
*
testing
.
T
)
{
parser
:=
&
InfluxdbQueryParser
{}
dsInfo
:=
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
(),
}
Convey
(
"can parse influxdb json model"
,
func
(
)
{
t
.
Run
(
"can parse influxdb json model"
,
func
(
t
*
testing
.
T
)
{
json
:=
`
{
"groupBy": [
...
...
@@ -107,20 +106,20 @@ func TestInfluxdbQueryParser(t *testing.T) {
}
`
dsInfo
.
JsonData
.
Set
(
"timeInterval"
,
">20s"
)
modelJson
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
So
(
err
,
ShouldBeNil
)
modelJSON
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
require
.
NoError
(
t
,
err
)
res
,
err
:=
parser
.
Parse
(
modelJson
,
dsInfo
)
So
(
err
,
ShouldBeNil
)
So
(
len
(
res
.
GroupBy
),
ShouldEqual
,
3
)
So
(
len
(
res
.
Selects
),
ShouldEqual
,
3
)
So
(
len
(
res
.
Tags
),
ShouldEqual
,
2
)
So
(
res
.
Tz
,
ShouldEqual
,
"Europe/Paris"
)
So
(
res
.
Interval
,
ShouldEqual
,
time
.
Second
*
20
)
So
(
res
.
Alias
,
ShouldEqual
,
"series alias"
)
res
,
err
:=
parser
.
Parse
(
modelJSON
,
dsInfo
)
require
.
NoError
(
t
,
err
)
require
.
Len
(
t
,
res
.
GroupBy
,
3
)
require
.
Len
(
t
,
res
.
Selects
,
3
)
require
.
Len
(
t
,
res
.
Tags
,
2
)
require
.
Equal
(
t
,
"Europe/Paris"
,
res
.
Tz
)
require
.
Equal
(
t
,
time
.
Second
*
20
,
res
.
Interval
)
require
.
Equal
(
t
,
"series alias"
,
res
.
Alias
)
})
Convey
(
"can part raw query json model"
,
func
(
)
{
t
.
Run
(
"can parse raw query json model"
,
func
(
t
*
testing
.
T
)
{
json
:=
`
{
"groupBy": [
...
...
@@ -165,16 +164,15 @@ func TestInfluxdbQueryParser(t *testing.T) {
}
`
modelJson
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
So
(
err
,
ShouldBeNil
)
modelJSON
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
require
.
NoError
(
t
,
err
)
res
,
err
:=
parser
.
Parse
(
modelJson
,
dsInfo
)
So
(
err
,
ShouldBeNil
)
So
(
res
.
RawQuery
,
ShouldEqual
,
"RawDummyQuery"
)
So
(
len
(
res
.
GroupBy
),
ShouldEqual
,
2
)
So
(
len
(
res
.
Selects
),
ShouldEqual
,
1
)
So
(
len
(
res
.
Tags
),
ShouldEqual
,
0
)
So
(
res
.
Interval
,
ShouldEqual
,
time
.
Second
*
10
)
})
res
,
err
:=
parser
.
Parse
(
modelJSON
,
dsInfo
)
require
.
NoError
(
t
,
err
)
require
.
Equal
(
t
,
"RawDummyQuery"
,
res
.
RawQuery
)
require
.
Len
(
t
,
res
.
GroupBy
,
2
)
require
.
Len
(
t
,
res
.
Selects
,
1
)
require
.
Empty
(
t
,
res
.
Tags
)
require
.
Equal
(
t
,
time
.
Second
*
10
,
res
.
Interval
)
})
}
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