mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
* break out query execution related logic * betterer fixes * remove unused * cleanup * remove unused variables * remove not used file * fix broken test * pr feedback * add comments
42 lines
1.4 KiB
TypeScript
42 lines
1.4 KiB
TypeScript
import { setupMockedAnnotationQueryRunner } from '../__mocks__/AnnotationQueryRunner';
|
|
import { namespaceVariable, regionVariable } from '../__mocks__/CloudWatchDataSource';
|
|
import { CloudWatchAnnotationQuery } from '../types';
|
|
|
|
describe('CloudWatchAnnotationQueryRunner', () => {
|
|
const queries: CloudWatchAnnotationQuery[] = [
|
|
{
|
|
actionPrefix: '',
|
|
alarmNamePrefix: '',
|
|
datasource: { type: 'cloudwatch' },
|
|
dimensions: { InstanceId: 'i-12345678' },
|
|
matchExact: true,
|
|
metricName: 'CPUUtilization',
|
|
period: '300',
|
|
prefixMatching: false,
|
|
queryMode: 'Annotations',
|
|
refId: 'Anno',
|
|
namespace: `$${namespaceVariable.name}`,
|
|
region: `$${regionVariable.name}`,
|
|
statistic: 'Average',
|
|
},
|
|
];
|
|
|
|
it('should issue the correct query', async () => {
|
|
const { runner, fetchMock, request } = setupMockedAnnotationQueryRunner({
|
|
variables: [namespaceVariable, regionVariable],
|
|
});
|
|
await expect(runner.handleAnnotationQuery(queries, request)).toEmitValuesWith(() => {
|
|
expect(fetchMock.mock.calls[0][0].data.queries[0]).toMatchObject(
|
|
expect.objectContaining({
|
|
region: regionVariable.current.value,
|
|
namespace: namespaceVariable.current.value,
|
|
metricName: queries[0].metricName,
|
|
dimensions: { InstanceId: ['i-12345678'] },
|
|
statistic: queries[0].statistic,
|
|
period: queries[0].period,
|
|
})
|
|
);
|
|
});
|
|
});
|
|
});
|