2014-08-07 03:42:05 -05:00
|
|
|
define([
|
2014-08-07 11:17:26 -05:00
|
|
|
'kbn'
|
|
|
|
], function(kbn) {
|
2014-08-07 03:42:05 -05:00
|
|
|
'use strict';
|
|
|
|
|
|
|
|
function ControllerTestContext() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.datasource = {};
|
2014-08-07 11:17:26 -05:00
|
|
|
this.annotationsSrv = {};
|
2014-08-07 03:42:05 -05:00
|
|
|
this.datasourceSrv = {
|
|
|
|
getMetricSources: function() {},
|
|
|
|
get: function() { return self.datasource; }
|
|
|
|
};
|
|
|
|
|
|
|
|
this.providePhase = function() {
|
|
|
|
return module(function($provide) {
|
|
|
|
$provide.value('datasourceSrv', self.datasourceSrv);
|
2014-08-07 11:17:26 -05:00
|
|
|
$provide.value('annotationsSrv', self.annotationsSrv);
|
2014-08-07 03:42:05 -05:00
|
|
|
});
|
|
|
|
};
|
|
|
|
|
|
|
|
this.createControllerPhase = function(controllerName) {
|
|
|
|
return inject(function($controller, $rootScope, $q) {
|
|
|
|
self.scope = $rootScope.$new();
|
|
|
|
self.scope.panel = {};
|
2014-08-08 10:33:00 -05:00
|
|
|
self.scope.filter = new FilterSrvStub();
|
2014-08-08 07:10:35 -05:00
|
|
|
$rootScope.colors = [];
|
|
|
|
for (var i = 0; i < 50; i++) { $rootScope.colors.push('#' + i); }
|
2014-08-07 11:17:26 -05:00
|
|
|
|
2014-08-07 03:42:05 -05:00
|
|
|
self.$q = $q;
|
|
|
|
self.scope.skipDataOnInit = true;
|
|
|
|
self.controller = $controller(controllerName, {
|
|
|
|
$scope: self.scope
|
|
|
|
});
|
|
|
|
|
|
|
|
});
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-08-08 10:33:00 -05:00
|
|
|
function ServiceTestContext() {
|
|
|
|
var self = this;
|
|
|
|
|
|
|
|
this.createService = function(name) {
|
|
|
|
return inject([name, '$q', '$rootScope', '$httpBackend', function(InfluxDatasource, $q, $rootScope, $httpBackend) {
|
|
|
|
self.service = InfluxDatasource;
|
|
|
|
self.$q = $q;
|
|
|
|
self.$rootScope = $rootScope;
|
|
|
|
self.filterSrv = new FilterSrvStub();
|
|
|
|
self.$httpBackend = $httpBackend;
|
|
|
|
}]);
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
|
|
|
function FilterSrvStub() {
|
|
|
|
this.time = { from:'now-1h', to: 'now'};
|
|
|
|
this.timeRange = function(parse) {
|
|
|
|
if (!parse) {
|
|
|
|
return this.time;
|
|
|
|
}
|
|
|
|
return {
|
|
|
|
from : kbn.parseDate(this.time.from),
|
|
|
|
to : kbn.parseDate(this.time.to)
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
this.applyTemplateToTarget = function(target) {
|
|
|
|
return target;
|
|
|
|
};
|
|
|
|
}
|
|
|
|
|
2014-08-07 03:42:05 -05:00
|
|
|
|
|
|
|
return {
|
2014-08-08 10:33:00 -05:00
|
|
|
ControllerTestContext: ControllerTestContext,
|
|
|
|
FilterSrvStub: FilterSrvStub,
|
|
|
|
ServiceTestContext: ServiceTestContext
|
2014-08-07 03:42:05 -05:00
|
|
|
};
|
|
|
|
|
|
|
|
});
|