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

36 lines
969 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 15:11:30 +03:00
fs.mkdirSync('tests/__data__/temp/database', { recursive: true })
fs.copyFileSync(
'tests/__data__/input/database/channels.db',
'tests/__data__/temp/database/channels.db'
)
2022-01-06 16:01:23 +03:00
2022-01-10 00:34:05 +03:00
execSync(
2022-01-10 15:11:30 +03:00
'DB_DIR=tests/__data__/temp/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
})
2022-01-10 15:11:30 +03:00
afterEach(() => {
fs.rmdirSync('tests/__data__/temp', { recursive: true })
})
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
})