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
c3a6ae16
Commit
c3a6ae16
authored
Aug 07, 2014
by
Torkel Ödegaard
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added more graphite target controller tests
parent
76aab2a2
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
93 additions
and
39 deletions
+93
-39
package.json
+28
-28
src/app/controllers/graphiteTarget.js
+1
-1
src/test/.jshintrc
+2
-2
src/test/karma.conf.js
+1
-1
src/test/specs/graphiteTargetCtrl-specs.js
+61
-7
No files found.
package.json
View file @
c3a6ae16
...
@@ -10,44 +10,44 @@
...
@@ -10,44 +10,44 @@
"url"
:
"
http://github.com/torkelo/grafana.git
"
"url"
:
"
http://github.com/torkelo/grafana.git
"
},
},
"devDependencies"
:
{
"devDependencies"
:
{
"
rjs-build-analysis
"
:
"0.0.3"
,
"
expect.js
"
:
"~0.2.0"
,
"
glob
"
:
"~3.2.7"
,
"
grunt
"
:
"~0.4.0"
,
"
grunt
"
:
"~0.4.0"
,
"
grunt-ngmin
"
:
"0.0.3"
,
"
grunt-angular-templates
"
:
"^0.5.5"
,
"
grunt-contrib-less
"
:
"~0.7.0"
,
"
grunt-cli
"
:
"~0.1.13"
,
"
grunt-contrib-copy
"
:
"~0.5.0"
,
"
grunt-git-describe
"
:
"~2.3.2"
,
"
grunt-contrib-clean
"
:
"~0.5.0"
,
"
grunt-contrib-clean
"
:
"~0.5.0"
,
"
grunt-contrib-compress
"
:
"~0.5.2"
,
"
grunt-contrib-concat
"
:
"^0.4.0"
,
"
grunt-contrib-connect
"
:
"~0.5.0"
,
"
grunt-contrib-copy
"
:
"~0.5.0"
,
"
grunt-contrib-cssmin
"
:
"~0.6.1"
,
"
grunt-contrib-cssmin
"
:
"~0.6.1"
,
"
grunt-contrib-jshint
"
:
"~0.10.0"
,
"
grunt-string-replace
"
:
"~0.2.4"
,
"
grunt-contrib-htmlmin
"
:
"~0.1.3"
,
"
grunt-contrib-htmlmin
"
:
"~0.1.3"
,
"
grunt-contrib-jshint
"
:
"~0.10.0"
,
"
grunt-contrib-less
"
:
"~0.7.0"
,
"
grunt-contrib-requirejs
"
:
"~0.4.1"
,
"
grunt-contrib-requirejs
"
:
"~0.4.1"
,
"
grunt-angular-templates
"
:
"^0.5.5"
,
"
grunt-contrib-compress
"
:
"~0.5.2"
,
"
grunt-contrib-uglify
"
:
"~0.2.4"
,
"
grunt-contrib-uglify
"
:
"~0.2.4"
,
"
load-grunt-tasks
"
:
"~0.2.0"
,
"
grunt-filerev
"
:
"^0.2.1"
,
"
glob
"
:
"~3.2.7"
,
"
grunt-git-describe
"
:
"~2.3.2"
,
"
grunt-contrib-connect
"
:
"~0.5.0"
,
"
grunt-karma
"
:
"~0.8.3"
,
"
mocha
"
:
"~1.16.1"
,
"
grunt-ngmin
"
:
"0.0.3"
,
"
expect.js
"
:
"~0.2.0"
,
"
grunt-string-replace
"
:
"~0.2.4"
,
"
karma-script-launcher
"
:
"~0.1.0"
,
"
grunt-usemin
"
:
"^2.1.1"
,
"
karma-firefox-launcher
"
:
"~0.1.3"
,
"
jshint-stylish
"
:
"~0.1.5"
,
"
karma
"
:
"~0.12.16"
,
"
karma-chrome-launcher
"
:
"~0.1.4"
,
"
karma-chrome-launcher
"
:
"~0.1.4"
,
"
karma-coffee-preprocessor
"
:
"~0.1.2"
,
"
karma-expect
"
:
"~1.1.0"
,
"
karma-firefox-launcher
"
:
"~0.1.3"
,
"
karma-html2js-preprocessor
"
:
"~0.1.0"
,
"
karma-html2js-preprocessor
"
:
"~0.1.0"
,
"
karma-jasmine
"
:
"~0.2.2"
,
"
karma-jasmine
"
:
"~0.2.2"
,
"
requirejs
"
:
"~2.1.14"
,
"
karma-requirejs
"
:
"~0.2.1"
,
"
karma-coffee-preprocessor
"
:
"~0.1.2"
,
"
karma-phantomjs-launcher
"
:
"~0.1.1"
,
"
karma
"
:
"~0.12.16"
,
"
grunt-karma
"
:
"~0.8.3"
,
"
karma-mocha
"
:
"~0.1.4"
,
"
karma-mocha
"
:
"~0.1.4"
,
"
karma-expect
"
:
"~1.1.0"
,
"
karma-phantomjs-launcher
"
:
"~0.1.1"
,
"
grunt-cli
"
:
"~0.1.13"
,
"
karma-requirejs
"
:
"~0.2.1"
,
"
jshint-stylish
"
:
"~0.1.5"
,
"
karma-script-launcher
"
:
"~0.1.0"
,
"
grunt-contrib-concat
"
:
"^0.4.0"
,
"
load-grunt-tasks
"
:
"~0.2.0"
,
"
grunt-usemin
"
:
"^2.1.1"
,
"
mocha
"
:
"~1.16.1"
,
"
grunt-filerev
"
:
"^0.2.1"
"
requirejs
"
:
"~2.1.14"
,
"
rjs-build-analysis
"
:
"0.0.3"
},
},
"engines"
:
{
"engines"
:
{
"node"
:
"0.10.x"
,
"node"
:
"0.10.x"
,
...
...
src/app/controllers/graphiteTarget.js
View file @
c3a6ae16
...
@@ -249,7 +249,7 @@ function (angular, _, config, gfunc, Parser) {
...
@@ -249,7 +249,7 @@ function (angular, _, config, gfunc, Parser) {
return
;
return
;
}
}
for
(
var
i
=
0
;
i
<
$scope
.
segments
.
length
;
i
++
)
{
for
(
var
i
=
0
;
i
<
$scope
.
segments
.
length
;
i
++
)
{
if
(
$scope
.
segments
[
i
].
val
.
indexOf
(
'*'
)
>=
0
)
{
if
(
$scope
.
segments
[
i
].
val
ue
.
indexOf
(
'*'
)
>=
0
)
{
func
.
params
[
0
]
=
i
;
func
.
params
[
0
]
=
i
;
func
.
added
=
false
;
func
.
added
=
false
;
$scope
.
targetChanged
();
$scope
.
targetChanged
();
...
...
src/test/.jshintrc
View file @
c3a6ae16
...
@@ -28,6 +28,7 @@
...
@@ -28,6 +28,7 @@
"expect": true,
"expect": true,
"it": true,
"it": true,
"describe": true,
"describe": true,
"sinon": true,
"define": true,
"define": true,
"module": true,
"module": true,
"beforeEach": true,
"beforeEach": true,
...
@@ -35,4 +36,4 @@
...
@@ -35,4 +36,4 @@
"require": true,
"require": true,
"setImmediate": true
"setImmediate": true
}
}
}
}
\ No newline at end of file
src/test/karma.conf.js
View file @
c3a6ae16
...
@@ -25,6 +25,6 @@ module.exports = function(config) {
...
@@ -25,6 +25,6 @@ module.exports = function(config) {
autoWatch
:
true
,
autoWatch
:
true
,
browsers
:
[
'Chrome'
],
browsers
:
[
'Chrome'
],
captureTimeout
:
60000
,
captureTimeout
:
60000
,
singleRun
:
false
singleRun
:
false
,
});
});
};
};
src/test/specs/graphiteTargetCtrl-specs.js
View file @
c3a6ae16
define
([
define
([
'./helpers'
,
'./helpers'
,
'services/graphite/gfunc'
,
'controllers/graphiteTarget'
'controllers/graphiteTarget'
],
function
(
helpers
)
{
],
function
(
helpers
,
gfunc
)
{
'use strict'
;
'use strict'
;
describe
(
'GraphiteTargetCtrl'
,
function
()
{
describe
(
'GraphiteTargetCtrl'
,
function
()
{
...
@@ -11,25 +12,78 @@ define([
...
@@ -11,25 +12,78 @@ define([
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
ctx
.
createControllerPhase
(
'GraphiteTargetCtrl'
));
beforeEach
(
ctx
.
createControllerPhase
(
'GraphiteTargetCtrl'
));
beforeEach
(
function
()
{
ctx
.
scope
.
target
=
{
target
:
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
};
ctx
.
scope
.
datasource
=
ctx
.
datasource
;
ctx
.
scope
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
});
describe
(
'init'
,
function
()
{
describe
(
'init'
,
function
()
{
beforeEach
(
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
=
{
target
:
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
};
ctx
.
scope
.
datasource
=
ctx
.
datasource
;
ctx
.
scope
.
datasource
.
metricFindQuery
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
ctx
.
scope
.
init
();
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
});
});
it
(
'should validate metric key exists'
,
function
()
{
it
(
'should validate metric key exists'
,
function
()
{
expect
(
ctx
.
scope
.
datasource
.
metricFindQuery
.
getCall
(
0
).
args
[
1
]).
to
.
be
(
'test.prod.*'
);
expect
(
ctx
.
scope
.
datasource
.
metricFindQuery
.
getCall
(
0
).
args
[
1
]).
to
.
be
(
'test.prod.*'
);
});
});
it
(
'should delete last segment if no metrics are found'
,
function
()
{
expect
(
ctx
.
scope
.
segments
[
2
].
value
).
to
.
be
(
'select metric'
);
});
it
(
'should parse expression and build function model'
,
function
()
{
it
(
'should parse expression and build function model'
,
function
()
{
expect
(
ctx
.
scope
.
functions
.
length
).
to
.
be
(
2
);
expect
(
ctx
.
scope
.
functions
.
length
).
to
.
be
(
2
);
});
});
});
describe
(
'when adding function'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
target
.
target
=
'test.prod.*.count'
;
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
ctx
.
scope
.
$parent
=
{
get_data
:
sinon
.
spy
()
};
ctx
.
scope
.
addFunction
(
gfunc
.
getFuncDef
(
'aliasByNode'
));
});
it
(
'should add function with correct node number'
,
function
()
{
expect
(
ctx
.
scope
.
functions
[
0
].
params
[
0
]).
to
.
be
(
2
);
});
it
(
'should update target'
,
function
()
{
expect
(
ctx
.
scope
.
target
.
target
).
to
.
be
(
'aliasByNode(test.prod.*.count,2)'
);
});
it
(
'should call get_data'
,
function
()
{
expect
(
ctx
.
scope
.
$parent
.
get_data
.
called
).
to
.
be
(
true
);
});
});
describe
(
'targetChanged'
,
function
()
{
beforeEach
(
function
()
{
ctx
.
scope
.
datasource
.
metricFindQuery
.
returns
(
ctx
.
$q
.
when
([{
expandable
:
false
}]));
ctx
.
scope
.
init
();
ctx
.
scope
.
$digest
();
ctx
.
scope
.
$parent
=
{
get_data
:
sinon
.
spy
()
};
ctx
.
scope
.
target
.
target
=
''
;
ctx
.
scope
.
targetChanged
();
});
it
(
'should rebuld target after expression model'
,
function
()
{
expect
(
ctx
.
scope
.
target
.
target
).
to
.
be
(
'aliasByNode(scaleToSeconds(test.prod.*,1),2)'
);
});
it
(
'should call get_data'
,
function
()
{
expect
(
ctx
.
scope
.
$parent
.
get_data
.
called
).
to
.
be
(
true
);
});
});
});
});
});
});
});
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