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
1bc277fd
Commit
1bc277fd
authored
Aug 09, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Plain Diff
Merge branch 'develop' into pro
parents
f068b2c1
5b475a05
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
112 additions
and
16 deletions
+112
-16
src/test/specs/helpers.js
+35
-14
src/test/specs/influxdb-datasource-specs.js
+75
-0
src/test/test-main.js
+1
-0
src/vendor/angular/angular-dragdrop.js
+1
-2
src/vendor/angular/angular-mocks.js
+0
-0
No files found.
src/test/specs/helpers.js
View file @
1bc277fd
...
...
@@ -6,7 +6,6 @@ define([
function
ControllerTestContext
()
{
var
self
=
this
;
this
.
timeRange
=
{
from
:
'now-1h'
,
to
:
'now'
};
this
.
datasource
=
{};
this
.
annotationsSrv
=
{};
this
.
datasourceSrv
=
{
...
...
@@ -25,18 +24,7 @@ define([
return
inject
(
function
(
$controller
,
$rootScope
,
$q
)
{
self
.
scope
=
$rootScope
.
$new
();
self
.
scope
.
panel
=
{};
self
.
scope
.
filter
=
{
timeRange
:
function
(
parse
)
{
if
(
!
parse
)
{
return
self
.
timeRange
;
}
return
{
from
:
kbn
.
parseDate
(
self
.
timeRange
.
from
),
to
:
kbn
.
parseDate
(
self
.
timeRange
.
to
)
};
}
};
self
.
scope
.
filter
=
new
FilterSrvStub
();
$rootScope
.
colors
=
[];
for
(
var
i
=
0
;
i
<
50
;
i
++
)
{
$rootScope
.
colors
.
push
(
'#'
+
i
);
}
...
...
@@ -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
{
ControllerTestContext
:
ControllerTestContext
ControllerTestContext
:
ControllerTestContext
,
FilterSrvStub
:
FilterSrvStub
,
ServiceTestContext
:
ServiceTestContext
};
});
src/test/specs/influxdb-datasource-specs.js
0 → 100644
View file @
1bc277fd
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
(
'When querying influxdb with one target using query editor target spec'
,
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'
);
});
});
describe
(
'When querying influxdb with one raw query'
,
function
()
{
var
results
;
var
urlExpected
=
"/series?p=mupp&q=select+value+from+series"
+
"+where+time+%3E+now()+-+1h+and+time+%3E+1&time_precision=s"
;
var
query
=
{
range
:
{
from
:
'now-1h'
,
to
:
'now'
},
targets
:
[{
query
:
"select value from series where time > 1"
,
rawQuery
:
true
}]
};
var
response
=
[];
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
();
});
});
});
});
src/test/test-main.js
View file @
1bc277fd
...
...
@@ -118,6 +118,7 @@ require([
'specs/parser-specs'
,
'specs/gfunc-specs'
,
'specs/graphiteTargetCtrl-specs'
,
'specs/influxdb-datasource-specs'
,
'specs/graph-ctrl-specs'
,
'specs/filterSrv-specs'
,
'specs/kbn-format-specs'
,
...
...
src/vendor/angular/angular-dragdrop.js
View file @
1bc277fd
...
...
@@ -330,4 +330,4 @@ var jqyoui = angular.module('ngDragDrop', []).service('ngDragDropService', ['$ti
return
element
.
getAttribute
(
name
)
||
element
.
getAttribute
(
'data-'
+
name
);
};
})(
window
,
window
.
angular
);
\ No newline at end of file
})(
window
,
window
.
angular
);
src/vendor/angular/angular-mocks.js
View file @
1bc277fd
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