mirror of
https://github.com/grafana/grafana.git
synced 2025-02-25 18:55:37 -06:00
Loki: Fix missing parameters on Query Builder operations (#60677)
* add missing mandatory params * improve naming * change let to const
This commit is contained in:
@@ -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) {
|
||||
|
||||
Reference in New Issue
Block a user