mirror of https://github.com/iptv-org/iptv
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
35 lines
964 B
JavaScript
35 lines
964 B
JavaScript
3 years ago
|
const fs = require('fs-extra')
|
||
|
const path = require('path')
|
||
|
const { execSync } = require('child_process')
|
||
|
|
||
|
beforeEach(() => {
|
||
|
fs.emptyDirSync('tests/__data__/output')
|
||
|
fs.emptyDirSync('tests/__data__/temp')
|
||
3 years ago
|
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/temp/streams.db')
|
||
3 years ago
|
|
||
|
const stdout = execSync(
|
||
3 years ago
|
'DB_DIR=tests/__data__/temp LOGS_DIR=tests/__data__/output/logs/load-cluster node scripts/commands/load-cluster.js --cluster-id=1 --timeout=1',
|
||
3 years ago
|
{ encoding: 'utf8' }
|
||
|
)
|
||
|
})
|
||
|
|
||
|
it('return results', () => {
|
||
3 years ago
|
let output = content('tests/__data__/output/logs/load-cluster/cluster_1.log')
|
||
|
let expected = content('tests/__data__/expected/logs/load-cluster/cluster_1.log')
|
||
3 years ago
|
|
||
|
expect(output).toEqual(expected)
|
||
|
})
|
||
|
|
||
|
function content(filepath) {
|
||
|
const data = fs.readFileSync(path.resolve(filepath), {
|
||
|
encoding: 'utf8'
|
||
|
})
|
||
|
|
||
|
return data
|
||
|
.split('\n')
|
||
|
.filter(l => l)
|
||
|
.map(l => {
|
||
|
return JSON.parse(l)
|
||
|
})
|
||
|
}
|