mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Azure Monitor: fixes undefined is not iterable (#25586)
* Azure Monitor: fixes undefined is not iterable * Update public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/response_parser.test.ts Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> * Update public/app/plugins/datasource/grafana-azure-monitor-datasource/azure_log_analytics/response_parser.test.ts Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com> Co-authored-by: Arve Knudsen <arve.knudsen@gmail.com>
This commit is contained in:
parent
04e0ee5cfc
commit
c0139b7d42
@ -0,0 +1,37 @@
|
|||||||
|
import ResponseParser from './response_parser';
|
||||||
|
import { expect } from '../../../../../test/lib/common';
|
||||||
|
|
||||||
|
describe('createSchemaFunctions', () => {
|
||||||
|
describe('when called and results have functions', () => {
|
||||||
|
it('then it should return correct result', () => {
|
||||||
|
const functions = [
|
||||||
|
{ name: 'some name', body: 'some body', displayName: 'some displayName', category: 'some category' },
|
||||||
|
];
|
||||||
|
const parser = new ResponseParser({ functions });
|
||||||
|
|
||||||
|
const results = parser.createSchemaFunctions();
|
||||||
|
|
||||||
|
expect(results).toEqual({
|
||||||
|
['some name']: {
|
||||||
|
Body: 'some body',
|
||||||
|
DocString: 'some displayName',
|
||||||
|
Folder: 'some category',
|
||||||
|
FunctionKind: 'Unknown',
|
||||||
|
InputParameters: [],
|
||||||
|
Name: 'some name',
|
||||||
|
OutputColumns: [],
|
||||||
|
},
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
describe('when called and results have no functions', () => {
|
||||||
|
it('then it should return an empty object', () => {
|
||||||
|
const parser = new ResponseParser({});
|
||||||
|
|
||||||
|
const results = parser.createSchemaFunctions();
|
||||||
|
|
||||||
|
expect(results).toEqual({});
|
||||||
|
});
|
||||||
|
});
|
||||||
|
});
|
@ -1,15 +1,14 @@
|
|||||||
import _ from 'lodash';
|
import _ from 'lodash';
|
||||||
import { dateTime } from '@grafana/data';
|
import { AnnotationEvent, dateTime, TimeSeries } from '@grafana/data';
|
||||||
import {
|
import {
|
||||||
AzureLogsVariable,
|
|
||||||
AzureLogsTableData,
|
AzureLogsTableData,
|
||||||
|
AzureLogsVariable,
|
||||||
|
KustoColumn,
|
||||||
KustoDatabase,
|
KustoDatabase,
|
||||||
KustoFunction,
|
KustoFunction,
|
||||||
KustoTable,
|
|
||||||
KustoSchema,
|
KustoSchema,
|
||||||
KustoColumn,
|
KustoTable,
|
||||||
} from '../types';
|
} from '../types';
|
||||||
import { TimeSeries, AnnotationEvent } from '@grafana/data';
|
|
||||||
|
|
||||||
export default class ResponseParser {
|
export default class ResponseParser {
|
||||||
columns: string[];
|
columns: string[];
|
||||||
@ -190,6 +189,9 @@ export default class ResponseParser {
|
|||||||
|
|
||||||
createSchemaFunctions(): { [key: string]: KustoFunction } {
|
createSchemaFunctions(): { [key: string]: KustoFunction } {
|
||||||
const functions: { [key: string]: KustoFunction } = {};
|
const functions: { [key: string]: KustoFunction } = {};
|
||||||
|
if (!this.results.functions) {
|
||||||
|
return functions;
|
||||||
|
}
|
||||||
|
|
||||||
for (const func of this.results.functions) {
|
for (const func of this.results.functions) {
|
||||||
functions[func.name] = {
|
functions[func.name] = {
|
||||||
|
Loading…
Reference in New Issue
Block a user