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