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/influxdb/specs/influx_query_specs.ts

37 lines
1.1 KiB

import {describe, beforeEach, it, sinon, expect} from 'test/lib/common';
import InfluxQuery = require('../influx_query');
describe.only('InfluxQuery', function() {
describe('series with mesurement only', function() {
it('should generate correct query', function() {
var query = new InfluxQuery({
measurement: 'cpu',
});
var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
});
});
describe('series with math and alias', function() {
it('should generate correct query', function() {
var query = new InfluxQuery({
measurement: 'cpu',
select: [
[
{name: 'field', params: ['value']},
{name: 'mean', params: []},
{name: 'math', params: ['/100']},
{name: 'alias', params: ['text']},
]
]
});
var queryText = query.render();
expect(queryText).to.be('SELECT mean("value") /100 AS "text" FROM "cpu" WHERE $timeFilter GROUP BY time($interval)');
});
});
});