mirror of
https://github.com/grafana/grafana.git
synced 2025-02-13 00:55:47 -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 { dateTime } from '@grafana/data';
|
||||
import { AnnotationEvent, dateTime, TimeSeries } from '@grafana/data';
|
||||
import {
|
||||
AzureLogsVariable,
|
||||
AzureLogsTableData,
|
||||
AzureLogsVariable,
|
||||
KustoColumn,
|
||||
KustoDatabase,
|
||||
KustoFunction,
|
||||
KustoTable,
|
||||
KustoSchema,
|
||||
KustoColumn,
|
||||
KustoTable,
|
||||
} from '../types';
|
||||
import { TimeSeries, AnnotationEvent } from '@grafana/data';
|
||||
|
||||
export default class ResponseParser {
|
||||
columns: string[];
|
||||
@ -190,6 +189,9 @@ export default class ResponseParser {
|
||||
|
||||
createSchemaFunctions(): { [key: string]: KustoFunction } {
|
||||
const functions: { [key: string]: KustoFunction } = {};
|
||||
if (!this.results.functions) {
|
||||
return functions;
|
||||
}
|
||||
|
||||
for (const func of this.results.functions) {
|
||||
functions[func.name] = {
|
||||
|
Loading…
Reference in New Issue
Block a user