mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
stackdriver: fix broken tests
This commit is contained in:
parent
1a91e0baf6
commit
85fce84087
@ -17,10 +17,6 @@ export class StackdriverAggregation {
|
|||||||
}
|
}
|
||||||
|
|
||||||
export class StackdriverAggregationCtrl {
|
export class StackdriverAggregationCtrl {
|
||||||
target: any;
|
|
||||||
alignOptions: any[];
|
|
||||||
aggOptions: any[];
|
|
||||||
|
|
||||||
constructor(private $scope) {
|
constructor(private $scope) {
|
||||||
$scope.aggOptions = options.aggOptions;
|
$scope.aggOptions = options.aggOptions;
|
||||||
this.setAggOptions();
|
this.setAggOptions();
|
||||||
|
@ -3,78 +3,60 @@ import { StackdriverAggregationCtrl } from '../query_aggregation_ctrl';
|
|||||||
describe('StackdriverAggregationCtrl', () => {
|
describe('StackdriverAggregationCtrl', () => {
|
||||||
let ctrl;
|
let ctrl;
|
||||||
describe('aggregation and alignment options', () => {
|
describe('aggregation and alignment options', () => {
|
||||||
beforeEach(() => {
|
|
||||||
ctrl = createCtrlWithFakes();
|
|
||||||
});
|
|
||||||
describe('when new query result is returned from the server', () => {
|
describe('when new query result is returned from the server', () => {
|
||||||
describe('and result is double and gauge', () => {
|
describe('and result is double and gauge', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
ctrl.target.valueType = 'DOUBLE';
|
ctrl = new StackdriverAggregationCtrl({
|
||||||
ctrl.target.metricKind = 'GAUGE';
|
$on: () => {},
|
||||||
|
target: { valueType: 'DOUBLE', metricKind: 'GAUGE', aggregation: { crossSeriesReducer: '' } },
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should populate all aggregate options except two', () => {
|
it('should populate all aggregate options except two', () => {
|
||||||
const result = ctrl.getAggOptions();
|
ctrl.setAggOptions();
|
||||||
expect(result.length).toBe(11);
|
expect(ctrl.$scope.aggOptions.length).toBe(11);
|
||||||
expect(result.map(o => o.value)).toEqual(
|
expect(ctrl.$scope.aggOptions.map(o => o.value)).toEqual(
|
||||||
expect.not.arrayContaining(['REDUCE_COUNT_TRUE', 'REDUCE_COUNT_FALSE'])
|
expect.not.arrayContaining(['REDUCE_COUNT_TRUE', 'REDUCE_COUNT_FALSE'])
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should populate all alignment options except two', () => {
|
it('should populate all alignment options except two', () => {
|
||||||
const result = ctrl.getAlignOptions();
|
ctrl.setAlignOptions();
|
||||||
expect(result.length).toBe(10);
|
expect(ctrl.$scope.alignOptions.length).toBe(10);
|
||||||
expect(result.map(o => o.value)).toEqual(
|
expect(ctrl.$scope.alignOptions.map(o => o.value)).toEqual(
|
||||||
expect.not.arrayContaining(['REDUCE_COUNT_TRUE', 'REDUCE_COUNT_FALSE'])
|
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 () => {
|
beforeEach(async () => {
|
||||||
ctrl.target.aggregation.crossSeriesReducer = 'RANDOM_REDUCER';
|
ctrl = new StackdriverAggregationCtrl({
|
||||||
|
$on: () => {},
|
||||||
|
refresh: () => {},
|
||||||
|
target: { aggregation: { crossSeriesReducer: 'RANDOM_REDUCER' } },
|
||||||
|
});
|
||||||
ctrl.onAlignmentChange('ALIGN_NONE');
|
ctrl.onAlignmentChange('ALIGN_NONE');
|
||||||
});
|
});
|
||||||
it('should set REDUCE_NONE as selected aggregation', () => {
|
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', () => {
|
describe('when a user a user select a reducer and no alignment is selected', () => {
|
||||||
beforeEach(async () => {
|
beforeEach(async () => {
|
||||||
ctrl.target.aggregation.crossSeriesReducer = 'REDUCE_NONE';
|
ctrl = new StackdriverAggregationCtrl({
|
||||||
ctrl.target.aggregation.perSeriesAligner = 'ALIGN_NONE';
|
$on: () => {},
|
||||||
|
refresh: () => {},
|
||||||
|
target: { aggregation: { crossSeriesReducer: 'REDUCE_NONE', perSeriesAligner: 'ALIGN_NONE' } },
|
||||||
|
});
|
||||||
ctrl.onAggregationChange('ALIGN_NONE');
|
ctrl.onAggregationChange('ALIGN_NONE');
|
||||||
});
|
});
|
||||||
|
|
||||||
it('should set an alignment', () => {
|
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: '',
|
|
||||||
};
|
|
||||||
}
|
|
||||||
|
Loading…
Reference in New Issue
Block a user