mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
sql: improve imports in test (#75006)
This commit is contained in:
parent
62d0becd25
commit
24350521be
@ -1,8 +1,8 @@
|
||||
import { render, waitFor } from '@testing-library/react';
|
||||
import React from 'react';
|
||||
|
||||
import { CustomVariableModel, LoadingState, VariableHide } from '@grafana/data';
|
||||
import { config } from '@grafana/runtime';
|
||||
import { customBuilder } from 'app/features/variables/shared/testing/builders';
|
||||
|
||||
import { SQLExpression } from '../types';
|
||||
|
||||
@ -69,16 +69,34 @@ describe('TableSelector', () => {
|
||||
});
|
||||
|
||||
describe('SQLWhereRow', () => {
|
||||
function makeVariable(id: string, name: string, multi: boolean): CustomVariableModel {
|
||||
return {
|
||||
id,
|
||||
name,
|
||||
multi,
|
||||
type: 'custom',
|
||||
includeAll: false,
|
||||
current: {},
|
||||
options: [],
|
||||
query: '',
|
||||
rootStateKey: null,
|
||||
global: false,
|
||||
hide: VariableHide.dontHide,
|
||||
skipUrlSync: false,
|
||||
index: -1,
|
||||
state: LoadingState.NotStarted,
|
||||
error: null,
|
||||
description: null,
|
||||
};
|
||||
}
|
||||
|
||||
it('should remove quotes in a where clause including multi-value variable', () => {
|
||||
const exp: SQLExpression = {
|
||||
whereString: "hostname IN ('${multiHost}')",
|
||||
};
|
||||
|
||||
const multiVar = customBuilder().withId('multiVar').withName('multiHost').build();
|
||||
const nonMultiVar = customBuilder().withId('nonMultiVar').withName('host').build();
|
||||
|
||||
multiVar.multi = true;
|
||||
nonMultiVar.multi = false;
|
||||
const multiVar = makeVariable('multiVar', 'multiHost', true);
|
||||
const nonMultiVar = makeVariable('nonMultiVar', 'host', false);
|
||||
|
||||
const variables = [multiVar, nonMultiVar];
|
||||
|
||||
@ -92,11 +110,8 @@ describe('SQLWhereRow', () => {
|
||||
whereString: "hostname IN ('${host}')",
|
||||
};
|
||||
|
||||
const multiVar = customBuilder().withId('multiVar').withName('multiHost').build();
|
||||
const nonMultiVar = customBuilder().withId('nonMultiVar').withName('host').build();
|
||||
|
||||
multiVar.multi = true;
|
||||
nonMultiVar.multi = false;
|
||||
const multiVar = makeVariable('multiVar', 'multiHost', true);
|
||||
const nonMultiVar = makeVariable('nonMultiVar', 'host', false);
|
||||
|
||||
const variables = [multiVar, nonMultiVar];
|
||||
|
||||
@ -110,11 +125,8 @@ describe('SQLWhereRow', () => {
|
||||
whereString: "hostname IN ('${nonMultiHost}')",
|
||||
};
|
||||
|
||||
const multiVar = customBuilder().withId('multiVar').withName('multiHost').build();
|
||||
const nonMultiVar = customBuilder().withId('nonMultiVar').withName('host').build();
|
||||
|
||||
multiVar.multi = true;
|
||||
nonMultiVar.multi = false;
|
||||
const multiVar = makeVariable('multiVar', 'multiHost', true);
|
||||
const nonMultiVar = makeVariable('nonMultiVar', 'host', false);
|
||||
|
||||
const variables = [multiVar, nonMultiVar];
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user