Skip to content

Commit

Permalink
feat(ui): test flux table parsing by time
Browse files Browse the repository at this point in the history
  • Loading branch information
sranka committed Aug 16, 2022
1 parent c0957d1 commit d591fc2
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions ui/test/shared/parsing/flux/parseTablesByTime.test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
import {parseResponse} from 'src/shared/parsing/flux/response'
import {SIMPLE, TAGS_RESPONSE} from 'test/shared/parsing/flux/constants'
import {parseTablesByTime} from 'src/shared/parsing/flux/parseTablesByTime'

describe('parseTablesByTime', () => {
it('can parse common flux table with simplified column names', () => {
const fluxTables = parseResponse(SIMPLE)
const actual = parseTablesByTime(fluxTables)
const expected = {
allColumnNames: [
'usage_guest measurement=cpu cpu=cpu1 host=bertrand.local',
],
nonNumericColumns: [],
tablesByTime: [
{
'1536618869000': {
'usage_guest measurement=cpu cpu=cpu1 host=bertrand.local': 0,
},
'1536618879000': {
'usage_guest measurement=cpu cpu=cpu1 host=bertrand.local': 10,
},
},
],
}

expect(actual).toEqual(expected)
})
it('can parse metadata flux response', () => {
const fluxTables = parseResponse(TAGS_RESPONSE)
const actual = parseTablesByTime(fluxTables)
const expected = {
allColumnNames: [],
nonNumericColumns: ['_value'],
tablesByTime: [],
}

expect(actual).toEqual(expected)
})
})

0 comments on commit d591fc2

Please sign in to comment.