Loki: Remove any type from logsModel.test.ts (#55287)

* Remove any type from logsModel.test.ts

* Remove duplicate type checks
This commit is contained in:
Gareth Dawson 2022-09-16 12:56:35 +01:00 committed by GitHub
parent 82a6872f0f
commit 5c66c41220
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 18 additions and 29 deletions

View File

@ -2778,17 +2778,6 @@ exports[`better eslint`] = {
"public/app/core/history/richHistoryLocalStorageUtils.ts:5381": [
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
],
"public/app/core/logsModel.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"],
[0, 0, 0, "Unexpected any. Specify a different type.", "5"],
[0, 0, 0, "Unexpected any. Specify a different type.", "6"],
[0, 0, 0, "Unexpected any. Specify a different type.", "7"],
[0, 0, 0, "Unexpected any. Specify a different type.", "8"]
],
"public/app/core/logsModel.ts:5381": [
[0, 0, 0, "Do not use any type assertions.", "0"],
[0, 0, 0, "Do not use any type assertions.", "1"]

View File

@ -32,19 +32,19 @@ import {
describe('dedupLogRows()', () => {
test('should return rows as is when dedup is set to none', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'WARN test 1.23 on [xxx]',
},
{
entry: 'WARN test 1.23 on [xxx]',
},
] as any;
] as LogRowModel[];
expect(dedupLogRows(rows, LogsDedupStrategy.none)).toMatchObject(rows);
});
test('should dedup on exact matches', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'WARN test 1.23 on [xxx]',
},
@ -57,7 +57,7 @@ describe('dedupLogRows()', () => {
{
entry: 'WARN test 1.23 on [xxx]',
},
] as any;
] as LogRowModel[];
expect(dedupLogRows(rows, LogsDedupStrategy.exact)).toEqual([
{
duplicates: 1,
@ -75,7 +75,7 @@ describe('dedupLogRows()', () => {
});
test('should dedup on number matches', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'WARN test 1.2323423 on [xxx]',
},
@ -88,7 +88,7 @@ describe('dedupLogRows()', () => {
{
entry: 'WARN test 1.23 on [xxx]',
},
] as any;
] as LogRowModel[];
expect(dedupLogRows(rows, LogsDedupStrategy.numbers)).toEqual([
{
duplicates: 1,
@ -106,7 +106,7 @@ describe('dedupLogRows()', () => {
});
test('should dedup on signature matches', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'WARN test 1.2323423 on [xxx]',
},
@ -119,7 +119,7 @@ describe('dedupLogRows()', () => {
{
entry: 'WARN test 1.23 on [xxx]',
},
] as any;
] as LogRowModel[];
expect(dedupLogRows(rows, LogsDedupStrategy.signature)).toEqual([
{
duplicates: 3,
@ -129,7 +129,7 @@ describe('dedupLogRows()', () => {
});
test('should return to non-deduped state on same log result', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'INFO 123',
},
@ -139,7 +139,7 @@ describe('dedupLogRows()', () => {
{
entry: 'WARN 123',
},
] as any;
] as LogRowModel[];
expect(dedupLogRows(rows, LogsDedupStrategy.exact)).toEqual([
{
duplicates: 0,
@ -157,7 +157,7 @@ describe('dedupLogRows()', () => {
describe('filterLogLevels()', () => {
test('should correctly filter out log levels', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'DEBUG 1',
logLevel: LogLevel.debug,
@ -170,7 +170,7 @@ describe('filterLogLevels()', () => {
entry: 'TRACE 1',
logLevel: LogLevel.trace,
},
] as any;
] as LogRowModel[];
const filteredLogs = filterLogLevels(rows, new Set([LogLevel.debug]));
expect(filteredLogs.length).toBe(2);
expect(filteredLogs).toEqual([
@ -179,7 +179,7 @@ describe('filterLogLevels()', () => {
]);
});
test('should correctly filter out log levels and then deduplicate', () => {
const rows: LogRowModel[] = [
const rows = [
{
entry: 'DEBUG 1',
logLevel: LogLevel.debug,
@ -200,7 +200,7 @@ describe('filterLogLevels()', () => {
entry: 'TRACE 1',
logLevel: LogLevel.trace,
},
] as any;
] as LogRowModel[];
const filteredLogs = filterLogLevels(rows, new Set([LogLevel.error]));
const deduplicatedLogs = dedupLogRows(filteredLogs, LogsDedupStrategy.exact);
expect(deduplicatedLogs.length).toBe(3);
@ -1083,10 +1083,10 @@ describe('getSeriesProperties()', () => {
});
it('does not adjust the bucketSize if the logs row times match the given range', () => {
const rows: LogRowModel[] = [
const rows = [
{ entry: 'foo', timeEpochMs: 10 },
{ entry: 'bar', timeEpochMs: 20 },
] as any;
] as LogRowModel[];
const range = { from: 10, to: 20 };
const result = getSeriesProperties(rows, 1, range, 2, 1);
expect(result.bucketSize).toBe(2);
@ -1094,10 +1094,10 @@ describe('getSeriesProperties()', () => {
});
it('clamps the range and adjusts the bucketSize if the logs row times do not completely cover the given range', () => {
const rows: LogRowModel[] = [
const rows = [
{ entry: 'foo', timeEpochMs: 10 },
{ entry: 'bar', timeEpochMs: 20 },
] as any;
] as LogRowModel[];
const range = { from: 0, to: 30 };
const result = getSeriesProperties(rows, 3, range, 2, 1);
// Bucketsize 6 gets shortened to 4 because of new visible range is 20ms vs original range being 30ms