mirror of
https://github.com/grafana/grafana.git
synced 2025-02-12 08:35:43 -06:00
* Initial schema - Add types based off of current frontend * Rename and field-level comments * Update report and regenerate files * Rename frontend Azure folder - Doing this for consistency and to ensure code-generation works - Update betterer results due to file renames * Remove default and add back enum vals that I deleted * Set workspace prop as optional * Replace template variable types * Connect frontend query types - Keep properties optional for now to avoid major changes - Rename AzureMetricResource - Correctly use ResultFormat * Add TSVeneer decorator * Update schema * Update type * Update CODEOWNERS * Fix gen-cue issue * Fix backend test * Fix e2e test * Update code coverage * Remove references to old Azure Monitor path * Review * Regen files
53 lines
1.9 KiB
TypeScript
53 lines
1.9 KiB
TypeScript
import { createMockInstanceSetttings } from './__mocks__/instanceSettings';
|
|
import createMockQuery from './__mocks__/query';
|
|
import Datasource from './datasource';
|
|
|
|
describe('Azure Monitor Datasource', () => {
|
|
describe('interpolateVariablesInQueries()', () => {
|
|
it('should interpolate variables in the queries', () => {
|
|
const ds = new Datasource(createMockInstanceSetttings());
|
|
const queries = [createMockQuery({ azureMonitor: { resources: [{ resourceGroup: '$resourceGroup' }] } })];
|
|
|
|
const interpolatedQueries = ds.interpolateVariablesInQueries(queries, {
|
|
resourceGroup: { text: 'the-resource-group', value: 'the-resource-group' },
|
|
});
|
|
|
|
expect(interpolatedQueries).toContainEqual(
|
|
expect.objectContaining({
|
|
azureMonitor: expect.objectContaining({
|
|
resources: [expect.objectContaining({ resourceGroup: 'the-resource-group' })],
|
|
}),
|
|
})
|
|
);
|
|
});
|
|
|
|
it('should include a datasource ref when interpolating queries', () => {
|
|
const ds = new Datasource(createMockInstanceSetttings());
|
|
const query = createMockQuery();
|
|
delete query.datasource;
|
|
const queries = [query];
|
|
|
|
const interpolatedQueries = ds.interpolateVariablesInQueries(queries, {});
|
|
|
|
expect(interpolatedQueries).toContainEqual(
|
|
expect.objectContaining({
|
|
datasource: expect.objectContaining({ type: 'azuremonitor', uid: 'abc' }),
|
|
})
|
|
);
|
|
});
|
|
});
|
|
|
|
it('should not filter a valid query', () => {
|
|
const ds = new Datasource(createMockInstanceSetttings());
|
|
const query = createMockQuery();
|
|
expect(ds.filterQuery(query)).toBe(true);
|
|
});
|
|
|
|
it('should filter out a query with no query type', () => {
|
|
const ds = new Datasource(createMockInstanceSetttings());
|
|
const query = createMockQuery();
|
|
delete query.queryType;
|
|
expect(ds.filterQuery(query)).toBe(false);
|
|
});
|
|
});
|