mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Remove any type from logs.test.ts (#55303)
* Remove any type from logs.test.ts * Replace unknown types and move type casting to variables
This commit is contained in:
parent
0c4d181d1e
commit
98a8908910
@ -860,13 +860,6 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"]
|
||||
],
|
||||
"packages/grafana-data/src/utils/logs.test.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "2"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "3"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "4"]
|
||||
],
|
||||
"packages/grafana-data/src/utils/logs.ts:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "1"],
|
||||
|
@ -1,4 +1,5 @@
|
||||
import { MutableDataFrame } from '../dataframe/MutableDataFrame';
|
||||
import { Labels } from '../types/data';
|
||||
import { LogLevel, LogsModel, LogRowModel, LogsSortOrder } from '../types/logs';
|
||||
|
||||
import {
|
||||
@ -66,11 +67,11 @@ describe('calculateLogsLabelStats()', () => {
|
||||
entry: 'foo 1',
|
||||
labels: {
|
||||
foo: 'bar',
|
||||
},
|
||||
} as Labels,
|
||||
},
|
||||
];
|
||||
] as LogRowModel[];
|
||||
|
||||
expect(calculateLogsLabelStats(rows as any, 'baz')).toEqual([]);
|
||||
expect(calculateLogsLabelStats(rows, 'baz')).toEqual([]);
|
||||
});
|
||||
|
||||
test('should return stats for found labels', () => {
|
||||
@ -79,23 +80,23 @@ describe('calculateLogsLabelStats()', () => {
|
||||
entry: 'foo 1',
|
||||
labels: {
|
||||
foo: 'bar',
|
||||
},
|
||||
} as Labels,
|
||||
},
|
||||
{
|
||||
entry: 'foo 0',
|
||||
labels: {
|
||||
foo: 'xxx',
|
||||
},
|
||||
} as Labels,
|
||||
},
|
||||
{
|
||||
entry: 'foo 2',
|
||||
labels: {
|
||||
foo: 'bar',
|
||||
},
|
||||
} as Labels,
|
||||
},
|
||||
];
|
||||
] as LogRowModel[];
|
||||
|
||||
expect(calculateLogsLabelStats(rows as any, 'foo')).toMatchObject([
|
||||
expect(calculateLogsLabelStats(rows, 'foo')).toMatchObject([
|
||||
{
|
||||
value: 'bar',
|
||||
count: 2,
|
||||
@ -215,9 +216,9 @@ describe('calculateFieldStats()', () => {
|
||||
{
|
||||
entry: 'foo=bar',
|
||||
},
|
||||
];
|
||||
] as LogRowModel[];
|
||||
|
||||
expect(calculateFieldStats(rows as any, /baz=(.*)/)).toEqual([]);
|
||||
expect(calculateFieldStats(rows, /baz=(.*)/)).toEqual([]);
|
||||
});
|
||||
|
||||
test('should return stats for found field', () => {
|
||||
@ -234,9 +235,9 @@ describe('calculateFieldStats()', () => {
|
||||
{
|
||||
entry: 't=2018-12-05T07:44:59+0000 foo=503',
|
||||
},
|
||||
];
|
||||
] as LogRowModel[];
|
||||
|
||||
expect(calculateFieldStats(rows as any, /foo=("[^"]*"|\S+)/)).toMatchObject([
|
||||
expect(calculateFieldStats(rows, /foo=("[^"]*"|\S+)/)).toMatchObject([
|
||||
{
|
||||
value: '"42 + 1"',
|
||||
count: 2,
|
||||
@ -363,8 +364,8 @@ describe('checkLogsError()', () => {
|
||||
labels: {
|
||||
__error__: 'Error Message',
|
||||
foo: 'boo',
|
||||
},
|
||||
} as any as LogRowModel;
|
||||
} as Labels,
|
||||
} as LogRowModel;
|
||||
test('should return correct error if error is present', () => {
|
||||
expect(checkLogsError(log)).toStrictEqual({ hasError: true, errorMessage: 'Error Message' });
|
||||
});
|
||||
|
Loading…
Reference in New Issue
Block a user