Loki: Fix missing parameters on Query Builder operations (#60677)

* add missing mandatory params

* improve naming

* change let to const
This commit is contained in:
Sven Grossmann
2022-12-22 15:31:41 +01:00
committed by GitHub
parent f990be58cb
commit 9f9bf4650d
3 changed files with 101 additions and 3 deletions

View File

@@ -586,6 +586,81 @@ describe('buildVisualQueryFromString', () => {
})
);
});
it('parses a regexp with empty string param', () => {
expect(buildVisualQueryFromString('{app="frontend"} | regexp "" ')).toEqual(
noErrors({
labels: [
{
op: '=',
value: 'frontend',
label: 'app',
},
],
operations: [{ id: LokiOperationId.Regexp, params: [''] }],
})
);
});
it('parses a regexp with no param', () => {
expect(buildVisualQueryFromString('{app="frontend"} | regexp ')).toEqual(
noErrors({
labels: [
{
op: '=',
value: 'frontend',
label: 'app',
},
],
operations: [{ id: LokiOperationId.Regexp, params: [''] }],
})
);
});
it('parses a pattern with empty string param', () => {
expect(buildVisualQueryFromString('{app="frontend"} | pattern "" ')).toEqual(
noErrors({
labels: [
{
op: '=',
value: 'frontend',
label: 'app',
},
],
operations: [{ id: LokiOperationId.Pattern, params: [''] }],
})
);
});
it('parses a pattern with no param', () => {
expect(buildVisualQueryFromString('{app="frontend"} | pattern ')).toEqual(
noErrors({
labels: [
{
op: '=',
value: 'frontend',
label: 'app',
},
],
operations: [{ id: LokiOperationId.Pattern, params: [''] }],
})
);
});
it('parses a json with no param', () => {
expect(buildVisualQueryFromString('{app="frontend"} | json ')).toEqual(
noErrors({
labels: [
{
op: '=',
value: 'frontend',
label: 'app',
},
],
operations: [{ id: LokiOperationId.Json, params: [] }],
})
);
});
});
function noErrors(query: LokiVisualQuery) {