Update cluster/load.js

Process will be terminated if programs not found
This commit is contained in:
Aleksandr Statciuk 2023-01-12 10:53:22 +03:00
parent ef6d151596
commit 67ef5aa13e
2 changed files with 41 additions and 24 deletions

View file

@ -5,17 +5,22 @@ const path = require('path')
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/output/queue.db')
execSync(
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs npm run cluster:load -- --cluster-id=1 --timeout=10000',
{ encoding: 'utf8' }
)
})
it('can load cluster', () => {
expect(content('tests/__data__/output/logs/cluster/load/cluster_1.log')).toEqual(
content('tests/__data__/expected/logs/cluster/load/cluster_1.log')
)
it('can load cluster and will terminate process if programs not found', () => {
try {
execSync(
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs npm run cluster:load -- --cluster-id=1 --timeout=10000',
{ encoding: 'utf8' }
)
process.exit(1)
} catch (err) {
expect(err.status).toBe(1)
expect(err.stdout.includes('Error: No programs found')).toBe(true)
expect(content('tests/__data__/output/logs/cluster/load/cluster_1.log')).toEqual(
content('tests/__data__/expected/logs/cluster/load/cluster_1.log')
)
}
})
function content(filepath) {