mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Fixed small bug in graphite target controller when having variable for single parameter function
This commit is contained in:
@@ -90,7 +90,7 @@ function (angular, _, config, gfunc, Parser) {
|
|||||||
break;
|
break;
|
||||||
case 'metric':
|
case 'metric':
|
||||||
if ($scope.segments.length > 0) {
|
if ($scope.segments.length > 0) {
|
||||||
if ($scope.segments[0].length !== 1) {
|
if (astNode.segments.length !== 1) {
|
||||||
throw { message: 'Multiple metric params not supported, use text editor.' };
|
throw { message: 'Multiple metric params not supported, use text editor.' };
|
||||||
}
|
}
|
||||||
addFunctionParameter(func, astNode.segments[0].value, index, true);
|
addFunctionParameter(func, astNode.segments[0].value, index, true);
|
||||||
|
|||||||
@@ -99,6 +99,25 @@ define([
|
|||||||
|
|
||||||
});
|
});
|
||||||
|
|
||||||
|
describe('when initializing a target with single param func using variable', function() {
|
||||||
|
beforeEach(function() {
|
||||||
|
ctx.scope.target.target = 'movingAverage(prod.count, $var)';
|
||||||
|
ctx.scope.datasource.metricFindQuery.returns(ctx.$q.when([]));
|
||||||
|
ctx.scope.init();
|
||||||
|
ctx.scope.$digest();
|
||||||
|
ctx.scope.$parent = { get_data: sinon.spy() };
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add 2 segments', function() {
|
||||||
|
expect(ctx.scope.segments.length).to.be(2);
|
||||||
|
});
|
||||||
|
|
||||||
|
it('should add function param', function() {
|
||||||
|
expect(ctx.scope.functions[0].params.length).to.be(1);
|
||||||
|
});
|
||||||
|
|
||||||
|
});
|
||||||
|
|
||||||
describe('when initalizing target without metric expression and function with series-ref', function() {
|
describe('when initalizing target without metric expression and function with series-ref', function() {
|
||||||
beforeEach(function() {
|
beforeEach(function() {
|
||||||
ctx.scope.target.target = 'asPercent(metric.node.count, #A)';
|
ctx.scope.target.target = 'asPercent(metric.node.count, #A)';
|
||||||
|
|||||||
Reference in New Issue
Block a user