add CloudWatch Annotation

This commit is contained in:
Mitsuhiro Tanda
2015-10-26 15:47:34 +09:00
parent 6beb9be42c
commit 1626982a3a
5 changed files with 159 additions and 1 deletions

View File

@@ -2,6 +2,7 @@
///<amd-dependency path="test/specs/helpers" name="helpers" />
import {describe, beforeEach, it, sinon, expect, angularMocks} from 'test/lib/common';
import moment = require('moment');
declare var helpers: any;
@@ -189,4 +190,50 @@ describe('CloudWatchDatasource', function() {
});
});
describe('When performing annotationQuery', function() {
var annotation = {
region: 'us-east-1',
namespace: 'AWS/EC2',
metricName: 'CPUUtilization',
dimensions: 'InstanceId=i-12345678'
};
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});
break;
case 'DescribeAlarmHistory':
return ctx.$q.when({data: historyResponse});
break;
}
};
});
it('should return annotation list', function(done) {
ctx.ds.annotationQuery(annotation, {from: moment(1443438674760), to: moment(1443460274760)}).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();
});
});
});