Commit 7d2646f6 by Torkel Ödegaard

refactor: moved influxdb specs to plugins folder

parent 1a8bc1dd
...@@ -2,10 +2,10 @@ define([ ...@@ -2,10 +2,10 @@ define([
'angular', 'angular',
'lodash', 'lodash',
'app/core/utils/datemath', 'app/core/utils/datemath',
'./influxSeries', './influx_series',
'./queryBuilder', './query_builder',
'./directives', './directives',
'./queryCtrl', './query_ctrl',
], ],
function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) { function (angular, _, dateMath, InfluxSeries, InfluxQueryBuilder) {
'use strict'; 'use strict';
......
define([ define([
'angular', 'angular',
'lodash', 'lodash',
'./queryBuilder', './query_builder',
], ],
function (angular, _, InfluxQueryBuilder) { function (angular, _, InfluxQueryBuilder) {
'use strict'; 'use strict';
......
define([ ///<amd-dependency path="app/plugins/datasource/influxdb/influx_series" name="InfluxSeries"/>
'app/plugins/datasource/influxdb/influxSeries'
], function(InfluxSeries) {
'use strict';
describe('when generating timeseries from influxdb response', function() { import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
declare var InfluxSeries: any;
describe('when generating timeseries from influxdb response', function() {
describe('given multiple fields for series', function() { describe('given multiple fields for series', function() {
var options = { series: [ var options = {
alias: '',
series: [
{ {
name: 'cpu', name: 'cpu',
tags: {app: 'test', server: 'server1'}, tags: {app: 'test', server: 'server1'},
columns: ['time', 'mean', 'max', 'min'], columns: ['time', 'mean', 'max', 'min'],
values: [[1431946625000, 10, 11, 9], [1431946626000, 20, 21, 19]] values: [[1431946625000, 10, 11, 9], [1431946626000, 20, 21, 19]]
} }
]}; ]
};
describe('and no alias', function() { describe('and no alias', function() {
it('should generate multiple datapoints for each column', function() { it('should generate multiple datapoints for each column', function() {
var series = new InfluxSeries(options); var series = new InfluxSeries(options);
...@@ -96,7 +100,9 @@ define([ ...@@ -96,7 +100,9 @@ define([
}); });
describe('given two series', function() { describe('given two series', function() {
var options = { series: [ var options = {
alias: '',
series: [
{ {
name: 'cpu', name: 'cpu',
tags: {app: 'test', server: 'server1'}, tags: {app: 'test', server: 'server1'},
...@@ -109,7 +115,8 @@ define([ ...@@ -109,7 +115,8 @@ define([
columns: ['time', 'mean'], columns: ['time', 'mean'],
values: [[1431946625000, 15], [1431946626000, 16]] values: [[1431946625000, 15], [1431946626000, 16]]
} }
]}; ]
};
describe('and no alias', function() { describe('and no alias', function() {
...@@ -158,14 +165,17 @@ define([ ...@@ -158,14 +165,17 @@ define([
}); });
describe('given measurement with dots', function() { describe('given measurement with dots', function() {
var options = { series: [ var options = {
alias: '',
series: [
{ {
name: 'app.prod.server1.count', name: 'app.prod.server1.count',
tags: {}, tags: {},
columns: ['time', 'mean'], columns: ['time', 'mean'],
values: [[1431946625000, 10], [1431946626000, 12]] values: [[1431946625000, 10], [1431946626000, 12]]
} }
]}; ]
};
it('should replace patterns', function() { it('should replace patterns', function() {
options.alias = 'alias: $1 -> [[3]]'; options.alias = 'alias: $1 -> [[3]]';
...@@ -175,6 +185,6 @@ define([ ...@@ -175,6 +185,6 @@ define([
expect(result[0].target).to.be('alias: prod -> count'); expect(result[0].target).to.be('alias: prod -> count');
}); });
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/influxdb/query_builder" name="InfluxQueryBuilder"/>
'app/plugins/datasource/influxdb/queryBuilder' //
], function(InfluxQueryBuilder) { import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
'use strict';
describe('InfluxQueryBuilder', function() { declare var InfluxQueryBuilder: any;
describe('InfluxQueryBuilder', function() {
describe('series with mesurement only', function() { describe('series with mesurement only', function() {
it('should generate correct query', function() { it('should generate correct query', function() {
...@@ -182,6 +183,4 @@ define([ ...@@ -182,6 +183,4 @@ define([
}); });
});
}); });
define([ ///<amd-dependency path="app/plugins/datasource/influxdb/query_ctrl"/>
'./helpers', ///<amd-dependency path="app/services/uiSegmentSrv" />
'app/plugins/datasource/influxdb/queryCtrl', ///<amd-dependency path="test/specs/helpers" name="helpers" />
'app/services/uiSegmentSrv'
], function(helpers) { import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
'use strict';
declare var helpers: any;
describe('InfluxDBQueryCtrl', function() {
describe('InfluxDBQueryCtrl', function() {
var ctx = new helpers.ControllerTestContext(); var ctx = new helpers.ControllerTestContext();
beforeEach(module('grafana.controllers')); beforeEach(angularMocks.module('grafana.controllers'));
beforeEach(module('grafana.services')); beforeEach(angularMocks.module('grafana.services'));
beforeEach(ctx.providePhase()); beforeEach(ctx.providePhase());
beforeEach(ctx.createControllerPhase('InfluxQueryCtrl')); beforeEach(ctx.createControllerPhase('InfluxQueryCtrl'));
...@@ -184,5 +185,4 @@ define([ ...@@ -184,5 +185,4 @@ define([
}); });
}); });
});
}); });
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment