mirror of
https://github.com/grafana/grafana.git
synced 2025-02-11 08:05:43 -06:00
Loki: Remove some of any assertions from tests (#53114)
* Loki: Remove some of any assertions from tests * Remove unnecessary as assertions
This commit is contained in:
parent
1c1f72b1aa
commit
3877964470
@ -7474,14 +7474,7 @@ exports[`better eslint`] = {
|
||||
[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"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "9"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "10"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "11"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "12"],
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "13"]
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "6"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/datasource.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
@ -7532,16 +7525,12 @@ exports[`better eslint`] = {
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
[0, 0, 0, "Do not use any type assertions.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilderContainer.test.tsx:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/querybuilder/components/LokiQueryBuilderContainer.tsx:5381": [
|
||||
[0, 0, 0, "Do not use any type assertions.", "0"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/querybuilder/components/LokiQueryEditorSelector.test.tsx: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.", "1"]
|
||||
],
|
||||
"public/app/plugins/datasource/loki/querybuilder/parsing.ts:5381": [
|
||||
[0, 0, 0, "Unexpected any. Specify a different type.", "0"],
|
||||
|
@ -9,6 +9,7 @@ import {
|
||||
DataFrame,
|
||||
dataFrameToJSON,
|
||||
DataQueryResponse,
|
||||
DataSourceInstanceSettings,
|
||||
dateTime,
|
||||
FieldType,
|
||||
LogRowModel,
|
||||
@ -24,7 +25,7 @@ import { CustomVariableModel } from '../../../features/variables/types';
|
||||
|
||||
import { LokiDatasource } from './datasource';
|
||||
import { makeMockLokiDatasource } from './mocks';
|
||||
import { LokiQuery, LokiQueryType } from './types';
|
||||
import { LokiOptions, LokiQuery, LokiQueryType } from './types';
|
||||
|
||||
const rawRange = {
|
||||
from: toUtc('2018-04-25 10:00'),
|
||||
@ -133,19 +134,19 @@ describe('LokiDatasource', () => {
|
||||
dsMaxLines: number | undefined,
|
||||
expectedMaxLines: number
|
||||
) => {
|
||||
let settings: any = {
|
||||
let settings = {
|
||||
url: 'myloggingurl',
|
||||
jsonData: {
|
||||
maxLines: dsMaxLines,
|
||||
},
|
||||
};
|
||||
} as DataSourceInstanceSettings<LokiOptions>;
|
||||
|
||||
const templateSrvMock = {
|
||||
getAdhocFilters: (): any[] => [],
|
||||
replace: (a: string) => a,
|
||||
} as unknown as TemplateSrv;
|
||||
|
||||
const ds = new LokiDatasource(settings, templateSrvMock, timeSrvStub as any);
|
||||
const ds = new LokiDatasource(settings, templateSrvMock, timeSrvStub);
|
||||
|
||||
// we need to check the final query before it is sent out,
|
||||
// and applyTemplateVariables is a convenient place to do that.
|
||||
@ -181,7 +182,11 @@ describe('LokiDatasource', () => {
|
||||
const DEFAULT_EXPR = 'rate({bar="baz", job="foo"} |= "bar" [5m])';
|
||||
const query: LokiQuery = { expr: DEFAULT_EXPR, refId: 'A' };
|
||||
const originalAdhocFiltersMock = templateSrvStub.getAdhocFilters();
|
||||
const ds = new LokiDatasource({} as any, templateSrvStub as any, timeSrvStub as any);
|
||||
const ds = new LokiDatasource(
|
||||
{} as DataSourceInstanceSettings,
|
||||
templateSrvStub as unknown as TemplateSrv,
|
||||
timeSrvStub
|
||||
);
|
||||
|
||||
afterAll(() => {
|
||||
templateSrvStub.getAdhocFilters.mockReturnValue(originalAdhocFiltersMock);
|
||||
@ -848,14 +853,14 @@ function createLokiDSForTests(
|
||||
replace: (a: string) => a,
|
||||
} as unknown as TemplateSrv
|
||||
): LokiDatasource {
|
||||
const instanceSettings: any = {
|
||||
const instanceSettings = {
|
||||
url: 'myloggingurl',
|
||||
};
|
||||
} as DataSourceInstanceSettings;
|
||||
|
||||
const customData = { ...(instanceSettings.jsonData || {}), maxLines: 20 };
|
||||
const customSettings = { ...instanceSettings, jsonData: customData };
|
||||
const customSettings: DataSourceInstanceSettings = { ...instanceSettings, jsonData: customData };
|
||||
|
||||
return new LokiDatasource(customSettings, templateSrvMock, timeSrvStub as any);
|
||||
return new LokiDatasource(customSettings, templateSrvMock, timeSrvStub as TimeSrv);
|
||||
}
|
||||
|
||||
function makeAnnotationQueryRequest(options: any): AnnotationQueryRequest<LokiQuery> {
|
||||
|
@ -1,6 +1,7 @@
|
||||
import { render, screen } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { DataSourcePluginMeta } from '@grafana/data';
|
||||
import { addOperation } from 'app/plugins/datasource/prometheus/querybuilder/shared/OperationList.testUtils';
|
||||
|
||||
import { LokiDatasource } from '../../datasource';
|
||||
@ -23,7 +24,7 @@ describe('LokiQueryBuilderContainer', () => {
|
||||
access: 'proxy',
|
||||
url: '',
|
||||
jsonData: {},
|
||||
meta: {} as any,
|
||||
meta: {} as DataSourcePluginMeta,
|
||||
},
|
||||
undefined,
|
||||
undefined
|
||||
|
@ -3,6 +3,7 @@ import userEvent from '@testing-library/user-event';
|
||||
import { cloneDeep, defaultsDeep } from 'lodash';
|
||||
import React from 'react';
|
||||
|
||||
import { DataSourcePluginMeta } from '@grafana/data';
|
||||
import { QueryEditorMode } from 'app/plugins/datasource/prometheus/querybuilder/shared/types';
|
||||
|
||||
import { LokiDatasource } from '../../datasource';
|
||||
@ -44,7 +45,7 @@ const datasource = new LokiDatasource(
|
||||
access: 'proxy',
|
||||
url: '',
|
||||
jsonData: {},
|
||||
meta: {} as any,
|
||||
meta: {} as DataSourcePluginMeta,
|
||||
},
|
||||
undefined,
|
||||
undefined
|
||||
|
Loading…
Reference in New Issue
Block a user