Files
epg/tests/commands/update-database.test.js

35 lines
806 B
JavaScript
Raw Normal View History

2022-01-09 18:36:39 +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-11 00:25:02 +03:00
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/input/logs node scripts/commands/update-database.js',
2022-01-09 18:36:39 +03:00
{ encoding: 'utf8' }
)
2022-01-10 00:34:05 +03:00
})
2022-01-11 00:25:02 +03:00
it('can update database', () => {
2022-01-10 00:34:05 +03:00
const output = fs.readFileSync(path.resolve('tests/__data__/output/database/programs.db'), {
2022-01-09 18:36:39 +03:00
encoding: 'utf8'
})
2022-01-10 00:34:05 +03:00
const lines = output.split('\n')
2022-01-09 18:36:39 +03:00
const parsed = JSON.parse(lines[0])
2022-01-10 00:34:05 +03:00
2022-01-09 19:23:57 +03:00
expect(Object.keys(parsed).sort()).toEqual([
'_id',
'category',
'channel',
'description',
'icon',
'lang',
'site',
'start',
'stop',
'title'
])
2022-01-09 18:36:39 +03:00
})