|
|
|
@ -1,7 +1,7 @@ |
|
|
|
|
import { CloudWatchDatasource } from './datasource'; |
|
|
|
|
import { TemplateSrv } from '../../../features/templating/template_srv'; |
|
|
|
|
import { DataQueryResponse, dateTime, DefaultTimeRange } from '@grafana/data'; |
|
|
|
|
import { setBackendSrv } from '@grafana/runtime'; |
|
|
|
|
import { DataQueryResponse, DefaultTimeRange } from '@grafana/data'; |
|
|
|
|
import { TemplateSrv } from '../../../features/templating/template_srv'; |
|
|
|
|
import { CloudWatchDatasource } from './datasource'; |
|
|
|
|
|
|
|
|
|
describe('datasource', () => { |
|
|
|
|
describe('query', () => { |
|
|
|
@ -35,6 +35,33 @@ describe('datasource', () => { |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('performTimeSeriesQuery', () => { |
|
|
|
|
it('should return the same length of data as result', async () => { |
|
|
|
|
const { datasource } = setup(); |
|
|
|
|
const awsRequestMock = jest.spyOn(datasource, 'awsRequest'); |
|
|
|
|
const buildCloudwatchConsoleUrlMock = jest.spyOn(datasource, 'buildCloudwatchConsoleUrl'); |
|
|
|
|
buildCloudwatchConsoleUrlMock.mockImplementation(() => ''); |
|
|
|
|
awsRequestMock.mockImplementation(async () => { |
|
|
|
|
return { |
|
|
|
|
results: { |
|
|
|
|
a: { refId: 'a', series: [{ name: 'cpu', points: [1, 1] }], meta: { gmdMeta: '' } }, |
|
|
|
|
b: { refId: 'b', series: [{ name: 'memory', points: [2, 2] }], meta: { gmdMeta: '' } }, |
|
|
|
|
}, |
|
|
|
|
}; |
|
|
|
|
}); |
|
|
|
|
const response: DataQueryResponse = await datasource.performTimeSeriesQuery( |
|
|
|
|
{ |
|
|
|
|
queries: [ |
|
|
|
|
{ datasourceId: 1, refId: 'a' }, |
|
|
|
|
{ datasourceId: 1, refId: 'b' }, |
|
|
|
|
], |
|
|
|
|
} as any, |
|
|
|
|
{ from: dateTime(), to: dateTime() } as any |
|
|
|
|
); |
|
|
|
|
expect(response.data.length).toEqual(2); |
|
|
|
|
}); |
|
|
|
|
}); |
|
|
|
|
|
|
|
|
|
describe('describeLogGroup', () => { |
|
|
|
|
it('replaces region correctly in the query', async () => { |
|
|
|
|
const { datasource, datasourceRequestMock } = setup(); |
|
|
|
|