Commit c0139b7d by Hugo Häggmark Committed by GitHub

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>
parent 04e0ee5c
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({});
});
});
});
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 { ...@@ -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] = {
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment