Fix client tests w/r/t changes to defaultQueryConfig and fill

pull/10616/head
Jared Scheib 2017-09-06 11:27:16 -04:00
parent fc0ddc0304
commit bd9b3ea9d5
3 changed files with 15 additions and 7 deletions

View File

@ -22,7 +22,7 @@ const fakeAddQueryAction = (panelID, queryID) => {
}
function buildInitialState(queryId, params) {
return Object.assign({}, defaultQueryConfig(queryId), params)
return Object.assign({}, defaultQueryConfig({id: queryId}), params)
}
describe('Chronograf.Reducers.DataExplorer.queryConfigs', () => {
@ -32,7 +32,7 @@ describe('Chronograf.Reducers.DataExplorer.queryConfigs', () => {
const state = reducer({}, fakeAddQueryAction('blah', queryId))
const actual = state[queryId]
const expected = defaultQueryConfig(queryId)
const expected = defaultQueryConfig({id: queryId})
expect(actual).to.deep.equal(expected)
})
@ -360,7 +360,7 @@ describe('Chronograf.Reducers.DataExplorer.queryConfigs', () => {
const initialState = {
[queryId]: buildInitialState(queryId),
}
const expected = defaultQueryConfig(queryId, {rawText: 'hello'})
const expected = defaultQueryConfig({id: queryId}, {rawText: 'hello'})
const action = updateQueryConfig(expected)
const nextState = reducer(initialState, action)

View File

@ -1,6 +1,8 @@
import buildInfluxQLQuery from 'utils/influxql'
import defaultQueryConfig from 'src/utils/defaultQueryConfig'
import {NULL_STRING} from 'shared/constants/queryFillOptions'
function mergeConfig(options) {
return Object.assign({}, defaultQueryConfig(123), options)
}
@ -87,13 +89,14 @@ describe('buildInfluxQLQuery', () => {
retentionPolicy: 'rp1',
fields: [{field: 'value', funcs: ['min']}],
groupBy: {time: '10m', tags: []},
fill: NULL_STRING,
})
timeBounds = {lower: 'now() - 12h'}
})
it('builds the right query', () => {
const expected =
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m)'
'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)
})
})
@ -145,13 +148,14 @@ describe('buildInfluxQLQuery', () => {
measurement: 'm0',
fields: [{field: 'value', funcs: ['min']}],
groupBy: {time: '10m', tags: ['t1', 't2']},
fill: NULL_STRING,
})
timeBounds = {lower: 'now() - 12h'}
})
it('builds the right query', () => {
const expected =
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m), "t1", "t2"'
'SELECT min("value") AS "min_value" FROM "db1"."rp1"."m0" WHERE time > now() - 12h GROUP BY time(10m), "t1", "t2" FILL(null)'
expect(buildInfluxQLQuery(timeBounds, config)).to.equal(expected)
})
})

View File

@ -19,7 +19,11 @@ const fakeAddQueryAction = (panelID, queryID) => {
}
function buildInitialState(queryId, params) {
return Object.assign({}, defaultQueryConfig(queryId), params)
return Object.assign(
{},
defaultQueryConfig({id: queryId, isKapacitorRule: true}),
params
)
}
describe('Chronograf.Reducers.Kapacitor.queryConfigs', () => {
@ -29,7 +33,7 @@ describe('Chronograf.Reducers.Kapacitor.queryConfigs', () => {
const state = reducer({}, fakeAddQueryAction('blah', queryId))
const actual = state[queryId]
const expected = defaultQueryConfig(queryId)
const expected = defaultQueryConfig({id: queryId, isKapacitorRule: true})
expect(actual).to.deep.equal(expected)
})