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
f69dcf38
Commit
f69dcf38
authored
Aug 08, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added unit test for influxdb query
parent
59c7edfd
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
85 additions
and
14 deletions
+85
-14
src/test/specs/helpers.js
+35
-14
src/test/specs/influxdb-datasource-specs.js
+49
-0
src/test/test-main.js
+1
-0
src/vendor/angular/angular-dragdrop.js
+0
-0
No files found.
src/test/specs/helpers.js
View file @
f69dcf38
...
@@ -6,7 +6,6 @@ define([
...
@@ -6,7 +6,6 @@ define([
function
ControllerTestContext
()
{
function
ControllerTestContext
()
{
var
self
=
this
;
var
self
=
this
;
this
.
timeRange
=
{
from
:
'now-1h'
,
to
:
'now'
};
this
.
datasource
=
{};
this
.
datasource
=
{};
this
.
annotationsSrv
=
{};
this
.
annotationsSrv
=
{};
this
.
datasourceSrv
=
{
this
.
datasourceSrv
=
{
...
@@ -25,18 +24,7 @@ define([
...
@@ -25,18 +24,7 @@ define([
return
inject
(
function
(
$controller
,
$rootScope
,
$q
)
{
return
inject
(
function
(
$controller
,
$rootScope
,
$q
)
{
self
.
scope
=
$rootScope
.
$new
();
self
.
scope
=
$rootScope
.
$new
();
self
.
scope
.
panel
=
{};
self
.
scope
.
panel
=
{};
self
.
scope
.
filter
=
{
self
.
scope
.
filter
=
new
FilterSrvStub
();
timeRange
:
function
(
parse
)
{
if
(
!
parse
)
{
return
self
.
timeRange
;
}
return
{
from
:
kbn
.
parseDate
(
self
.
timeRange
.
from
),
to
:
kbn
.
parseDate
(
self
.
timeRange
.
to
)
};
}
};
$rootScope
.
colors
=
[];
$rootScope
.
colors
=
[];
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
...
@@ -50,9 +38,42 @@ define([
...
@@ -50,9 +38,42 @@ define([
};
};
}
}
function
ServiceTestContext
()
{
var
self
=
this
;
this
.
createService
=
function
(
name
)
{
return
inject
([
name
,
'$q'
,
'$rootScope'
,
'$httpBackend'
,
function
(
InfluxDatasource
,
$q
,
$rootScope
,
$httpBackend
)
{
self
.
service
=
InfluxDatasource
;
self
.
$q
=
$q
;
self
.
$rootScope
=
$rootScope
;
self
.
filterSrv
=
new
FilterSrvStub
();
self
.
$httpBackend
=
$httpBackend
;
}]);
};
}
function
FilterSrvStub
()
{
this
.
time
=
{
from
:
'now-1h'
,
to
:
'now'
};
this
.
timeRange
=
function
(
parse
)
{
if
(
!
parse
)
{
return
this
.
time
;
}
return
{
from
:
kbn
.
parseDate
(
this
.
time
.
from
),
to
:
kbn
.
parseDate
(
this
.
time
.
to
)
};
};
this
.
applyTemplateToTarget
=
function
(
target
)
{
return
target
;
};
}
return
{
return
{
ControllerTestContext
:
ControllerTestContext
ControllerTestContext
:
ControllerTestContext
,
FilterSrvStub
:
FilterSrvStub
,
ServiceTestContext
:
ServiceTestContext
};
};
});
});
src/test/specs/influxdb-datasource-specs.js
0 → 100644
View file @
f69dcf38
define
([
'./helpers'
,
'services/influxdb/influxdbDatasource'
],
function
(
helpers
)
{
'use strict'
;
describe
(
'InfluxDatasource'
,
function
()
{
var
ctx
=
new
helpers
.
ServiceTestContext
();
beforeEach
(
module
(
'grafana.services'
));
beforeEach
(
ctx
.
createService
(
'InfluxDatasource'
));
describe
(
'query with 2 targets'
,
function
()
{
var
results
;
var
urlExpected
=
"/series?p=mupp&q=select++mean(value)+from+%22test%22"
+
"+where++time+%3E+now()+-+1h+++++group+by+time()++order+asc&time_precision=s"
;
var
query
=
{
range
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
series
:
'test'
,
column
:
'value'
,
function
:
'mean'
}]
};
var
response
=
[{
columns
:
[
"time"
,
"sequence_nr"
,
"value"
],
name
:
'test'
,
points
:
[[
10
,
1
,
1
]],
}];
beforeEach
(
function
()
{
var
ds
=
new
ctx
.
service
({
urls
:
[
''
],
user
:
'test'
,
password
:
'mupp'
});
ctx
.
$httpBackend
.
expect
(
'GET'
,
urlExpected
).
respond
(
response
);
ds
.
query
(
ctx
.
filterSrv
,
query
).
then
(
function
(
data
)
{
results
=
data
;
});
ctx
.
$httpBackend
.
flush
();
});
it
(
'should generate the correct query'
,
function
()
{
ctx
.
$httpBackend
.
verifyNoOutstandingExpectation
();
});
it
(
'should return series list'
,
function
()
{
expect
(
results
.
data
.
length
).
to
.
be
(
1
);
expect
(
results
.
data
[
0
].
target
).
to
.
be
(
'test.value'
);
});
});
});
});
src/test/test-main.js
View file @
f69dcf38
...
@@ -118,6 +118,7 @@ require([
...
@@ -118,6 +118,7 @@ require([
'specs/parser-specs'
,
'specs/parser-specs'
,
'specs/gfunc-specs'
,
'specs/gfunc-specs'
,
'specs/graphiteTargetCtrl-specs'
,
'specs/graphiteTargetCtrl-specs'
,
'specs/influxdb-datasource-specs'
,
'specs/graph-ctrl-specs'
,
'specs/graph-ctrl-specs'
,
'specs/filterSrv-specs'
,
'specs/filterSrv-specs'
,
'specs/kbn-format-specs'
,
'specs/kbn-format-specs'
,
...
...
src/vendor/angular/angular-dragdrop.js
View file @
f69dcf38
This diff is collapsed.
Click to expand it.
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