Add comprehensive explicit fill test coverage

pull/1885/head
Jared Scheib 2017-09-06 11:44:22 -04:00
parent 2bf7d64370
commit 7ac1057e0d
1 changed files with 35 additions and 4 deletions

View File

@ -1,7 +1,7 @@
import buildInfluxQLQuery from 'utils/influxql'
import defaultQueryConfig from 'src/utils/defaultQueryConfig'
import {NULL_STRING} from 'shared/constants/queryFillOptions'
import {NONE, NULL_STRING} from 'shared/constants/queryFillOptions'
function mergeConfig(options) {
return Object.assign({}, defaultQueryConfig(123), options)
@ -222,8 +222,9 @@ describe('buildInfluxQLQuery', () => {
})
})
describe('and explicit fill', () => {
it('includes explicit fill(null)', () => {
describe('and explicit fills', () => {
it('includes those explicit fills', () => {
// Test fill null
config = mergeConfig({
database: 'db1',
retentionPolicy: 'rp1',
@ -234,9 +235,39 @@ describe('buildInfluxQLQuery', () => {
})
timeBounds = {lower: 'now() - 12h'}
const expected =
let expected =
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m) FILL(null)'
expect(buildInfluxQLQuery(timeBounds, config)).to.equal(expected)
// Test fill another option
config = mergeConfig({
database: 'db1',
retentionPolicy: 'rp1',
measurement: 'm0',
fields: [{field: 'value', funcs: ['min']}],
groupBy: {time: '10m', tags: []},
fill: NONE,
})
timeBounds = {lower: 'now() - 12h'}
expected =
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m) FILL(none)'
expect(buildInfluxQLQuery(timeBounds, config)).to.equal(expected)
// Test fill number
config = mergeConfig({
database: 'db1',
retentionPolicy: 'rp1',
measurement: 'm0',
fields: [{field: 'value', funcs: ['min']}],
groupBy: {time: '10m', tags: ['t1', 't2']},
fill: '1337',
})
timeBounds = {lower: 'now() - 12h'}
expected =
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m), "t1", "t2" FILL(1337)'
expect(buildInfluxQLQuery(timeBounds, config)).to.equal(expected)
})
})
})