Skip to content

Commit

Permalink
test: add delay to test
Browse files Browse the repository at this point in the history
  • Loading branch information
tkurki committed Sep 15, 2022
1 parent e7928c1 commit e4a33df
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 23 deletions.
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"@types/wait-on": "^5.3.1",
"@typescript-eslint/eslint-plugin": "^5.33.1",
"@typescript-eslint/parser": "^5.33.1",
"async-await-retry": "^2.0.0",
"chai": "^4.3.6",
"eslint": "^8.22.0",
"eslint-config-prettier": "^8.5.0",
Expand Down
51 changes: 28 additions & 23 deletions src/plugin.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ import { ZonedDateTime } from '@js-joda/core'
import { EventEmitter } from 'stream'
import InfluxPluginFactory, { App } from './plugin'
import waitOn from 'wait-on'
import retry from 'async-await-retry'

const INFLUX_HOST = process.env['INFLUX_HOST'] || '127.0.0.1'

Expand Down Expand Up @@ -84,29 +85,33 @@ describe('Plugin', () => {
return (
plugin
.flush()
.then(() => new Promise((resolve) => setTimeout(resolve, 500)))
.then(() => {
return Promise.all(
TESTVALUES.reduce((acc, values) => {
acc = acc.concat(
values.map((pathValue) =>
plugin
.getValues({
context: TESTCONTEXT,
from: ZonedDateTime.parse('2022-08-17T17:00:00Z'),
to: ZonedDateTime.parse('2022-08-17T17:00:00Z'),
paths: [pathValue.path],
resolution: 60,
})
.then((rows) => {
expect(rows.length).to.equal(pathValue.rowCount)
}),
),
)
return acc
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}, new Array<any[]>()),
)
.then(async () => {
const testAllValuesFoundInDb = async () =>
Promise.all(
TESTVALUES.reduce((acc, values) => {
acc = acc.concat(
values.map((pathValue) =>
plugin
.getValues({
context: TESTCONTEXT,
from: ZonedDateTime.parse('2022-08-17T17:00:00Z'),
to: ZonedDateTime.parse('2022-08-17T17:00:00Z'),
paths: [pathValue.path],
resolution: 60,
})
.then((rows) => {
expect(rows.length).to.equal(pathValue.rowCount)
}),
),
)
return acc
// eslint-disable-next-line @typescript-eslint/no-explicit-any
}, new Array<any[]>()),
)
return await retry(testAllValuesFoundInDb, [null], {
retriesMax: 10,
interval: 50,
})
})
// eslint-disable-next-line @typescript-eslint/no-explicit-any
.then((results: any[][]) => {
Expand Down

0 comments on commit e4a33df

Please sign in to comment.