mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
(cloudwatch) refactor annotation query
This commit is contained in:
@@ -187,59 +187,4 @@ describe('CloudWatchDatasource', function() {
|
||||
expect(scenario.request.data.action).to.be('ListMetrics');
|
||||
});
|
||||
});
|
||||
|
||||
describe('When performing annotationQuery', function() {
|
||||
var parameter = {
|
||||
annotation: {
|
||||
region: 'us-east-1',
|
||||
namespace: 'AWS/EC2',
|
||||
metricName: 'CPUUtilization',
|
||||
dimensions: {
|
||||
InstanceId: 'i-12345678'
|
||||
},
|
||||
statistics: ['Average'],
|
||||
period: 300
|
||||
},
|
||||
range: {
|
||||
from: moment(1443438674760),
|
||||
to: moment(1443460274760)
|
||||
}
|
||||
};
|
||||
var alarmResponse = {
|
||||
MetricAlarms: [
|
||||
{
|
||||
AlarmName: 'test_alarm_name'
|
||||
}
|
||||
]
|
||||
};
|
||||
var historyResponse = {
|
||||
AlarmHistoryItems: [
|
||||
{
|
||||
Timestamp: '2015-01-01T00:00:00.000Z',
|
||||
HistoryItemType: 'StateUpdate',
|
||||
AlarmName: 'test_alarm_name',
|
||||
HistoryData: '{}',
|
||||
HistorySummary: 'test_history_summary'
|
||||
}
|
||||
]
|
||||
};
|
||||
beforeEach(function() {
|
||||
ctx.backendSrv.datasourceRequest = function(params) {
|
||||
switch (params.data.action) {
|
||||
case 'DescribeAlarmsForMetric':
|
||||
return ctx.$q.when({data: alarmResponse});
|
||||
case 'DescribeAlarmHistory':
|
||||
return ctx.$q.when({data: historyResponse});
|
||||
}
|
||||
};
|
||||
});
|
||||
it('should return annotation list', function(done) {
|
||||
ctx.ds.annotationQuery(parameter).then(function(result) {
|
||||
expect(result[0].title).to.be('test_alarm_name');
|
||||
expect(result[0].text).to.be('test_history_summary');
|
||||
done();
|
||||
});
|
||||
ctx.$rootScope.$apply();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user