Skip to content

Commit

Permalink
fix flaky test
Browse files Browse the repository at this point in the history
  • Loading branch information
juliangruber committed Apr 27, 2023
1 parent 3b69d13 commit 616b769
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 9 deletions.
15 changes: 14 additions & 1 deletion package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,8 @@
"mocha": "^10.2.0",
"np": "^7.6.3",
"prettier": "^2.8.4",
"standard": "^17.0.0"
"standard": "^17.0.0",
"stream-match": "^3.0.2"
},
"dependencies": {
"@influxdata/influxdb-client": "^1.33.2",
Expand Down
12 changes: 5 additions & 7 deletions test/station.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import { tmpdir } from 'node:os'
import assert from 'node:assert'
import { randomUUID } from 'node:crypto'
import { join } from 'node:path'
import streamMatch from 'stream-match'

describe('Station', () => {
it('runs Saturn', async () => {
Expand Down Expand Up @@ -33,14 +34,11 @@ describe('Station', () => {
[],
{ env: { CACHE_ROOT, STATE_ROOT, FIL_WALLET_ADDRESS } }
)
const events = []
for await (const line of ps.stdout) {
events.push(line.toString().trim())
if (events.length === 2) break
}
await Promise.all([
streamMatch(ps.stdout, 'totalJobsCompleted'),
streamMatch(ps.stdout, 'Saturn Node will try to connect')
])
ps.kill()
assert.strictEqual(events[0], '{\n "totalJobsCompleted": 0,\n "totalEarnings": "0"\n}')
assert.match(events[1], /^\[.+\] INFO {2}Saturn Node will try to connect to the Saturn Orchestrator\.\.\.$/)
})
it('outputs events json', async () => {
const CACHE_ROOT = join(tmpdir(), randomUUID())
Expand Down

0 comments on commit 616b769

Please sign in to comment.