Files
epg/tests/commands/load-cluster.test.js

27 lines
702 B
JavaScript
Raw Normal View History

2022-01-06 16:01:23 +03:00
const fs = require('fs')
const path = require('path')
const { execSync } = require('child_process')
beforeEach(() => {
fs.rmdirSync('tests/__data__/output', { recursive: true })
fs.mkdirSync('tests/__data__/output')
2022-01-10 00:34:05 +03:00
execSync(
2022-01-09 20:14:41 +03:00
'DB_DIR=tests/__data__/input/database LOGS_DIR=tests/__data__/output/logs node scripts/commands/load-cluster.js --cluster-id=1',
2022-01-06 16:01:23 +03:00
{ encoding: 'utf8' }
)
2022-01-10 00:34:05 +03:00
})
it('can load cluster', () => {
const output = fs.readFileSync(
2022-01-06 16:01:23 +03:00
path.resolve('tests/__data__/output/logs/load-cluster/cluster_1.log'),
{
encoding: 'utf8'
}
)
2022-01-10 00:34:05 +03:00
const lines = output.split('\n')
2022-01-06 16:01:23 +03:00
const parsed = JSON.parse(lines[0])
2022-01-10 00:34:05 +03:00
2022-01-10 15:00:35 +03:00
expect(parsed._id).toBe('1XzrxNkSF2AQNBrT')
2022-01-06 16:01:23 +03:00
})