The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/loki/responseUtils.test.ts

41 lines
1.0 KiB

import { cloneDeep } from 'lodash';
import { ArrayVector, DataFrame, FieldType } from '@grafana/data';
import { dataFrameHasLokiError } from './responseUtils';
const frame: DataFrame = {
length: 1,
fields: [
{
name: 'Time',
config: {},
type: FieldType.time,
values: new ArrayVector([1]),
},
{
name: 'labels',
config: {},
type: FieldType.other,
values: new ArrayVector([{ level: 'info' }]),
},
{
name: 'Line',
config: {},
type: FieldType.string,
values: new ArrayVector(['line1']),
},
],
};
describe('dataframeHasParsingError', () => {
it('handles frame with parsing error', () => {
const input = cloneDeep(frame);
input.fields[1].values = new ArrayVector([{ level: 'info', __error__: 'error' }]);
expect(dataFrameHasLokiError(input)).toBe(true);
});
it('handles frame without parsing error', () => {
const input = cloneDeep(frame);
expect(dataFrameHasLokiError(input)).toBe(false);
});
});