mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
(cloudwatch) add test for expand templater variables
This commit is contained in:
parent
540436e9d5
commit
481cc01242
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user