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
85fce840
Commit
85fce840
authored
Sep 26, 2018
by
Erik Sundell
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
stackdriver: fix broken tests
parent
1a91e0ba
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
23 additions
and
45 deletions
+23
-45
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
+0
-4
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
+23
-41
No files found.
public/app/plugins/datasource/stackdriver/query_aggregation_ctrl.ts
View file @
85fce840
...
...
@@ -17,10 +17,6 @@ export class StackdriverAggregation {
}
export
class
StackdriverAggregationCtrl
{
target
:
any
;
alignOptions
:
any
[];
aggOptions
:
any
[];
constructor
(
private
$scope
)
{
$scope
.
aggOptions
=
options
.
aggOptions
;
this
.
setAggOptions
();
...
...
public/app/plugins/datasource/stackdriver/specs/query_aggregation_ctrl.test.ts
View file @
85fce840
...
...
@@ -3,78 +3,60 @@ import { StackdriverAggregationCtrl } from '../query_aggregation_ctrl';
describe
(
'StackdriverAggregationCtrl'
,
()
=>
{
let
ctrl
;
describe
(
'aggregation and alignment options'
,
()
=>
{
beforeEach
(()
=>
{
ctrl
=
createCtrlWithFakes
();
});
describe
(
'when new query result is returned from the server'
,
()
=>
{
describe
(
'and result is double and gauge'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
.
target
.
valueType
=
'DOUBLE'
;
ctrl
.
target
.
metricKind
=
'GAUGE'
;
ctrl
=
new
StackdriverAggregationCtrl
({
$on
:
()
=>
{},
target
:
{
valueType
:
'DOUBLE'
,
metricKind
:
'GAUGE'
,
aggregation
:
{
crossSeriesReducer
:
''
}
},
});
});
it
(
'should populate all aggregate options except two'
,
()
=>
{
c
onst
result
=
ctrl
.
g
etAggOptions
();
expect
(
result
.
length
).
toBe
(
11
);
expect
(
result
.
map
(
o
=>
o
.
value
)).
toEqual
(
c
trl
.
s
etAggOptions
();
expect
(
ctrl
.
$scope
.
aggOptions
.
length
).
toBe
(
11
);
expect
(
ctrl
.
$scope
.
aggOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
.
not
.
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
);
});
it
(
'should populate all alignment options except two'
,
()
=>
{
c
onst
result
=
ctrl
.
g
etAlignOptions
();
expect
(
result
.
length
).
toBe
(
10
);
expect
(
result
.
map
(
o
=>
o
.
value
)).
toEqual
(
c
trl
.
s
etAlignOptions
();
expect
(
ctrl
.
$scope
.
alignOptions
.
length
).
toBe
(
10
);
expect
(
ctrl
.
$scope
.
alignOptions
.
map
(
o
=>
o
.
value
)).
toEqual
(
expect
.
not
.
arrayContaining
([
'REDUCE_COUNT_TRUE'
,
'REDUCE_COUNT_FALSE'
])
);
});
});
});
describe
(
'when a user
a user select
ALIGN_NONE and a reducer is selected'
,
()
=>
{
describe
(
'when a user
selects
ALIGN_NONE and a reducer is selected'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
.
target
.
aggregation
.
crossSeriesReducer
=
'RANDOM_REDUCER'
;
ctrl
=
new
StackdriverAggregationCtrl
({
$on
:
()
=>
{},
refresh
:
()
=>
{},
target
:
{
aggregation
:
{
crossSeriesReducer
:
'RANDOM_REDUCER'
}
},
});
ctrl
.
onAlignmentChange
(
'ALIGN_NONE'
);
});
it
(
'should set REDUCE_NONE as selected aggregation'
,
()
=>
{
expect
(
ctrl
.
target
.
aggregation
.
crossSeriesReducer
).
toBe
(
'REDUCE_NONE'
);
expect
(
ctrl
.
$scope
.
target
.
aggregation
.
crossSeriesReducer
).
toBe
(
'REDUCE_NONE'
);
});
});
describe
(
'when a user a user select a reducer and no alignment is selected'
,
()
=>
{
beforeEach
(
async
()
=>
{
ctrl
.
target
.
aggregation
.
crossSeriesReducer
=
'REDUCE_NONE'
;
ctrl
.
target
.
aggregation
.
perSeriesAligner
=
'ALIGN_NONE'
;
ctrl
=
new
StackdriverAggregationCtrl
({
$on
:
()
=>
{},
refresh
:
()
=>
{},
target
:
{
aggregation
:
{
crossSeriesReducer
:
'REDUCE_NONE'
,
perSeriesAligner
:
'ALIGN_NONE'
}
},
});
ctrl
.
onAggregationChange
(
'ALIGN_NONE'
);
});
it
(
'should set an alignment'
,
()
=>
{
expect
(
ctrl
.
target
.
aggregation
.
perSeriesAligner
).
not
.
toBe
(
'ALIGN_NONE'
);
expect
(
ctrl
.
$scope
.
target
.
aggregation
.
perSeriesAligner
).
not
.
toBe
(
'ALIGN_NONE'
);
});
});
});
});
function
createCtrlWithFakes
()
{
StackdriverAggregationCtrl
.
prototype
.
target
=
createTarget
();
return
new
StackdriverAggregationCtrl
({
refresh
:
()
=>
{}
});
}
function
createTarget
(
existingFilters
?:
string
[])
{
return
{
project
:
{
id
:
''
,
name
:
''
,
},
metricType
:
'ametric'
,
refId
:
'A'
,
aggregation
:
{
crossSeriesReducer
:
''
,
alignmentPeriod
:
''
,
perSeriesAligner
:
''
,
groupBys
:
[],
},
filters
:
existingFilters
||
[],
aliasBy
:
''
,
};
}
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