Files
grafana/packages/grafana-sql/src/utils/migration.test.ts
T
Gábor Farkas 29e8a355cb sql: extract frontend code into separate package (#81109)
* sql: extract frontend code into separate package

* updated package version
2024-01-26 11:38:29 +01:00

29 lines
844 B
TypeScript

import { QueryFormat } from '../types';
import migrateAnnotation from './migration';
describe('Annotation migration', () => {
const annotation = {
datasource: {
uid: 'P4FDCC188E688367F',
type: 'mysql',
},
enable: false,
hide: false,
iconColor: 'rgba(0, 211, 255, 1)',
limit: 100,
name: 'Single',
rawQuery:
"SELECT\n createdAt as time,\n 'single' as text,\n hostname as tags\nFROM\n grafana_metric\nWHERE\n $__timeFilter(createdAt)\nORDER BY time\nLIMIT 1\n",
showIn: 0,
tags: [],
type: 'tags',
};
it('should migrate from old format to new', () => {
const newAnnotationFormat = migrateAnnotation(annotation);
expect(newAnnotationFormat.target?.format).toBe(QueryFormat.Table);
expect(newAnnotationFormat.target?.rawSql).toBe(annotation.rawQuery);
});
});