Commit 481cc012 by Mitsuhiro Tanda

(cloudwatch) add test for expand templater variables

parent 540436e9
......@@ -98,6 +98,38 @@ describe('CloudWatchDatasource', function() {
});
ctx.$rootScope.$apply();
});
it('should generate the correct targets by expanding template variables', function() {
var templateSrv = {
variables: [
{
name: 'instance_id',
options: [
{ value: 'i-23456789', selected: false },
{ value: 'i-34567890', selected: true }
]
}
],
variableExists: function (e) { return true; },
containsVariable: function (str, variableName) { return str.indexOf('$' + variableName) !== -1; }
};
var targets = [
{
region: 'us-east-1',
namespace: 'AWS/EC2',
metricName: 'CPUUtilization',
dimensions: {
InstanceId: '$instance_id'
},
statistics: ['Average'],
period: 300
}
];
var result = ctx.ds.expandTemplateVariable(targets, templateSrv);
expect(result[0].dimensions.InstanceId).to.be('i-34567890');
});
});
function describeMetricFindQuery(query, func) {
......
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