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
4aa5dab6
Commit
4aa5dab6
authored
Feb 17, 2016
by
utkarshcmu
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Added query ctrl tests for Opentsdb
parent
936dd2ea
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
85 additions
and
0 deletions
+85
-0
public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts
+85
-0
No files found.
public/app/plugins/datasource/opentsdb/specs/query-ctrl-specs.ts
0 → 100644
View file @
4aa5dab6
import
{
describe
,
beforeEach
,
it
,
sinon
,
expect
,
angularMocks
}
from
'test/lib/common'
;
import
helpers
from
'test/specs/helpers'
;
import
{
OpenTsQueryCtrl
}
from
"../query_ctrl"
;
describe
(
'OpenTsQueryCtrl'
,
function
()
{
var
ctx
=
new
helpers
.
ControllerTestContext
();
beforeEach
(
angularMocks
.
module
(
'grafana.core'
));
beforeEach
(
angularMocks
.
module
(
'grafana.services'
));
beforeEach
(
ctx
.
providePhase
([
'backendSrv'
,
'templateSrv'
]));
beforeEach
(
ctx
.
providePhase
());
beforeEach
(
angularMocks
.
inject
((
$rootScope
,
$controller
,
$q
)
=>
{
ctx
.
$q
=
$q
;
ctx
.
scope
=
$rootScope
.
$new
();
ctx
.
target
=
{
target
:
''
};
ctx
.
panelCtrl
=
{
panel
:
{}};
ctx
.
panelCtrl
.
refresh
=
sinon
.
spy
();
ctx
.
datasource
.
getAggregators
=
sinon
.
stub
().
returns
(
ctx
.
$q
.
when
([]));
ctx
.
ctrl
=
$controller
(
OpenTsQueryCtrl
,
{
$scope
:
ctx
.
scope
},
{
panelCtrl
:
ctx
.
panelCtrl
,
datasource
:
ctx
.
datasource
,
target
:
ctx
.
target
,
});
ctx
.
scope
.
$digest
();
}));
describe
(
'init query_ctrl variables'
,
function
()
{
it
(
'filter types should be initialized'
,
function
()
{
expect
(
ctx
.
ctrl
.
filterTypes
.
length
).
to
.
be
(
7
);
});
it
(
'aggregators should be initialized'
,
function
()
{
expect
(
ctx
.
ctrl
.
aggregators
.
length
).
to
.
be
(
8
);
});
it
(
'fill policy options should be initialized'
,
function
()
{
expect
(
ctx
.
ctrl
.
fillPolicies
.
length
).
to
.
be
(
4
);
});
});
describe
(
'when adding filters and tags'
,
function
()
{
it
(
'addTagMode should be false when closed'
,
function
()
{
ctx
.
ctrl
.
addTagMode
=
true
;
ctx
.
ctrl
.
closeAddTagMode
();
expect
(
ctx
.
ctrl
.
addTagMode
).
to
.
be
(
false
);
});
it
(
'addFilterMode should be false when closed'
,
function
()
{
ctx
.
ctrl
.
addFilterMode
=
true
;
ctx
.
ctrl
.
closeAddFilterMode
();
expect
(
ctx
.
ctrl
.
addFilterMode
).
to
.
be
(
false
);
});
it
(
'removing a tag from the tags list'
,
function
()
{
ctx
.
ctrl
.
target
.
tags
=
{
"tagk"
:
"tag_key"
,
"tagk2"
:
"tag_value2"
};
ctx
.
ctrl
.
removeTag
(
"tagk"
);
expect
(
Object
.
keys
(
ctx
.
ctrl
.
target
.
tags
).
length
).
to
.
be
(
1
);
});
it
(
'removing a filter from the filters list'
,
function
()
{
ctx
.
ctrl
.
target
.
filters
=
[{
"tagk"
:
"tag_key"
,
"filter"
:
"tag_value2"
,
"type"
:
"wildcard"
,
"groupBy"
:
true
}];
ctx
.
ctrl
.
removeFilter
(
0
);
expect
(
ctx
.
ctrl
.
target
.
filters
.
length
).
to
.
be
(
0
);
});
it
(
'adding a filter when tags exist should generate error'
,
function
()
{
ctx
.
ctrl
.
target
.
tags
=
{
"tagk"
:
"tag_key"
,
"tagk2"
:
"tag_value2"
};
ctx
.
ctrl
.
addFilter
();
expect
(
ctx
.
ctrl
.
errors
.
filters
).
to
.
be
(
'Please remove tags to use filters, tags and filters are mutually exclusive.'
);
});
it
(
'adding a tag when filters exist should generate error'
,
function
()
{
ctx
.
ctrl
.
target
.
filters
=
[{
"tagk"
:
"tag_key"
,
"filter"
:
"tag_value2"
,
"type"
:
"wildcard"
,
"groupBy"
:
true
}];
ctx
.
ctrl
.
addTag
();
expect
(
ctx
.
ctrl
.
errors
.
tags
).
to
.
be
(
'Please remove filters to use tags, tags and filters are mutually exclusive.'
);
});
});
});
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