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
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
31 additions
and
33 deletions
+31
-33
pkg/tsdb/influxdb/model_parser_test.go
+31
-33
No files found.
pkg/tsdb/influxdb/model_parser_test.go
View file @
5c0094fe
...
@@ -6,18 +6,17 @@ import (
...
@@ -6,18 +6,17 @@ import (
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/components/simplejson"
"github.com/grafana/grafana/pkg/models"
"github.com/grafana/grafana/pkg/models"
.
"github.com/smartystreets/goconvey/convey
"
"github.com/stretchr/testify/require
"
)
)
func
TestInfluxdbQueryParser
(
t
*
testing
.
T
)
{
func
TestInfluxdbQueryParser_Parse
(
t
*
testing
.
T
)
{
Convey
(
"Influxdb query parser"
,
t
,
func
()
{
parser
:=
&
InfluxdbQueryParser
{}
parser
:=
&
InfluxdbQueryParser
{}
dsInfo
:=
&
models
.
DataSource
{
dsInfo
:=
&
models
.
DataSource
{
JsonData
:
simplejson
.
New
(),
JsonData
:
simplejson
.
New
(),
}
}
Convey
(
"can parse influxdb json model"
,
func
(
)
{
t
.
Run
(
"can parse influxdb json model"
,
func
(
t
*
testing
.
T
)
{
json
:=
`
json
:=
`
{
{
"groupBy": [
"groupBy": [
{
{
...
@@ -106,22 +105,22 @@ func TestInfluxdbQueryParser(t *testing.T) {
...
@@ -106,22 +105,22 @@ func TestInfluxdbQueryParser(t *testing.T) {
]
]
}
}
`
`
dsInfo
.
JsonData
.
Set
(
"timeInterval"
,
">20s"
)
dsInfo
.
JsonData
.
Set
(
"timeInterval"
,
">20s"
)
modelJson
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
modelJSON
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
So
(
err
,
ShouldBeNil
)
require
.
NoError
(
t
,
err
)
res
,
err
:=
parser
.
Parse
(
modelJson
,
dsInfo
)
res
,
err
:=
parser
.
Parse
(
modelJSON
,
dsInfo
)
So
(
err
,
ShouldBeNil
)
require
.
NoError
(
t
,
err
)
So
(
len
(
res
.
GroupBy
),
ShouldEqual
,
3
)
require
.
Len
(
t
,
res
.
GroupBy
,
3
)
So
(
len
(
res
.
Selects
),
ShouldEqual
,
3
)
require
.
Len
(
t
,
res
.
Selects
,
3
)
So
(
len
(
res
.
Tags
),
ShouldEqual
,
2
)
require
.
Len
(
t
,
res
.
Tags
,
2
)
So
(
res
.
Tz
,
ShouldEqual
,
"Europe/Paris"
)
require
.
Equal
(
t
,
"Europe/Paris"
,
res
.
Tz
)
So
(
res
.
Interval
,
ShouldEqual
,
time
.
Second
*
20
)
require
.
Equal
(
t
,
time
.
Second
*
20
,
res
.
Interval
)
So
(
res
.
Alias
,
ShouldEqual
,
"series alias"
)
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
:=
`
json
:=
`
{
{
"groupBy": [
"groupBy": [
{
{
...
@@ -165,16 +164,15 @@ func TestInfluxdbQueryParser(t *testing.T) {
...
@@ -165,16 +164,15 @@ func TestInfluxdbQueryParser(t *testing.T) {
}
}
`
`
modelJson
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
modelJSON
,
err
:=
simplejson
.
NewJson
([]
byte
(
json
))
So
(
err
,
ShouldBeNil
)
require
.
NoError
(
t
,
err
)
res
,
err
:=
parser
.
Parse
(
modelJson
,
dsInfo
)
res
,
err
:=
parser
.
Parse
(
modelJSON
,
dsInfo
)
So
(
err
,
ShouldBeNil
)
require
.
NoError
(
t
,
err
)
So
(
res
.
RawQuery
,
ShouldEqual
,
"RawDummyQuery"
)
require
.
Equal
(
t
,
"RawDummyQuery"
,
res
.
RawQuery
)
So
(
len
(
res
.
GroupBy
),
ShouldEqual
,
2
)
require
.
Len
(
t
,
res
.
GroupBy
,
2
)
So
(
len
(
res
.
Selects
),
ShouldEqual
,
1
)
require
.
Len
(
t
,
res
.
Selects
,
1
)
So
(
len
(
res
.
Tags
),
ShouldEqual
,
0
)
require
.
Empty
(
t
,
res
.
Tags
)
So
(
res
.
Interval
,
ShouldEqual
,
time
.
Second
*
10
)
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