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
67f25383
Commit
67f25383
authored
Sep 30, 2015
by
Jimmi Dyson
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add Prometheus metricFindQuery unit tests
parent
59dbe457
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
49 additions
and
4 deletions
+49
-4
public/test/specs/prometheus-datasource-specs.js
+49
-4
No files found.
public/test/specs/prometheus-datasource-specs.js
View file @
67f25383
define
([
define
([
'./helpers'
,
'./helpers'
,
'moment'
,
'moment'
,
'app/plugins/datasource/prometheus/datasource'
,
'app/plugins/datasource/prometheus/datasource'
'app/services/backendSrv'
,
'app/services/alertSrv'
],
function
(
helpers
,
moment
)
{
],
function
(
helpers
,
moment
)
{
'use strict'
;
'use strict'
;
...
@@ -11,7 +9,6 @@ define([
...
@@ -11,7 +9,6 @@ define([
var
ctx
=
new
helpers
.
ServiceTestContext
();
var
ctx
=
new
helpers
.
ServiceTestContext
();
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'templateSrv'
]));
beforeEach
(
ctx
.
createService
(
'PrometheusDatasource'
));
beforeEach
(
ctx
.
createService
(
'PrometheusDatasource'
));
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
ds
=
new
ctx
.
service
({
url
:
''
,
user
:
'test'
,
password
:
'mupp'
});
ctx
.
ds
=
new
ctx
.
service
({
url
:
''
,
user
:
'test'
,
password
:
'mupp'
});
...
@@ -56,6 +53,54 @@ define([
...
@@ -56,6 +53,54 @@ define([
});
});
describe
(
'When performing metricFindQuery'
,
function
()
{
var
results
;
var
response
;
it
(
'label_values(resource) should generate label search query'
,
function
()
{
response
=
{
status
:
"success"
,
data
:
[
"value1"
,
"value2"
,
"value3"
]
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
'/api/v1/label/resource/values'
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'label_values(resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
expect
(
results
.
length
).
to
.
be
(
3
);
});
it
(
'label_values(metric, resource) should generate count metric query'
,
function
()
{
response
=
{
status
:
"success"
,
data
:{
resultType
:
"vector"
,
result
:[
{
metric
:{
resource
:
"value1"
},
value
:[]},
{
metric
:{
resource
:
"value2"
},
value
:[]},
{
metric
:{
resource
:
"value3"
},
value
:[]}
]
}
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
/
\/
api
\/
v1
\/
query
\?
query=count
\(
metric
\)
%20by%20
\(
resource
\)
&time=.*/
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'label_values(metric, resource)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
expect
(
results
.
length
).
to
.
be
(
3
);
});
it
(
'metrics(metric.*) should generate metric name query'
,
function
()
{
response
=
{
status
:
"success"
,
data
:[
"metric1"
,
"metric2"
,
"metric3"
,
"nomatch"
]
};
ctx
.
$httpBackend
.
expect
(
'GET'
,
'/api/v1/label/__name__/values'
).
respond
(
response
);
ctx
.
ds
.
metricFindQuery
(
'metrics(metric.*)'
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
ctx
.
$rootScope
.
$apply
();
expect
(
results
.
length
).
to
.
be
(
3
);
});
});
});
});
});
});
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