The open and composable observability and data visualization platform. Visualize metrics, logs, and traces from multiple sources like Prometheus, Loki, Elasticsearch, InfluxDB, Postgres and many more.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 
grafana/public/app/plugins/datasource/loki/migrations/variableQueryMigrations.tes...

48 lines
1.4 KiB

import { LokiVariableQuery, LokiVariableQueryType } from '../types';
import { migrateVariableQuery } from './variableQueryMigrations';
describe('Loki migrateVariableQuery()', () => {
it('Does not migrate LokiVariableQuery instances', () => {
const query: LokiVariableQuery = {
refId: 'test',
type: LokiVariableQueryType.LabelValues,
label: 'label',
stream: 'stream',
};
expect(migrateVariableQuery(query)).toBe(query);
expect(migrateVariableQuery(query)).toStrictEqual(query);
});
it('Migrates label_names() queries', () => {
const query = 'label_names()';
expect(migrateVariableQuery(query)).toStrictEqual({
refId: 'LokiVariableQueryEditor-VariableQuery',
type: LokiVariableQueryType.LabelNames,
});
});
it('Migrates label_values(label) queries', () => {
const query = 'label_values(label)';
expect(migrateVariableQuery(query)).toStrictEqual({
refId: 'LokiVariableQueryEditor-VariableQuery',
type: LokiVariableQueryType.LabelValues,
label: 'label',
stream: undefined,
});
});
it('Migrates label_values(log stream selector, label) queries', () => {
const query = 'label_values(log stream selector, label)';
expect(migrateVariableQuery(query)).toStrictEqual({
refId: 'LokiVariableQueryEditor-VariableQuery',
type: LokiVariableQueryType.LabelValues,
label: 'label',
stream: 'log stream selector',
});
});
});