mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Created commands/create-database.js
This commit is contained in:
parent
5c95098fea
commit
f5dbc9376e
12 changed files with 29999 additions and 1 deletions
29
tests/commands/create-database.test.js
Normal file
29
tests/commands/create-database.test.js
Normal file
|
@ -0,0 +1,29 @@
|
|||
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')
|
||||
})
|
||||
|
||||
it('can create database', () => {
|
||||
const results = execSync(
|
||||
'DB_FILEPATH=tests/__data__/output/test.db node scripts/commands/create-database.js --channels=tests/__data__/input/site.channels.xml --max-clusters=1',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
|
||||
const database = fs.readFileSync(path.resolve('tests/__data__/output/test.db'), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
const item = database.split('\n').find(i => i.includes('AndorraTV.ad'))
|
||||
expect(JSON.parse(item)).toMatchObject({
|
||||
name: 'Andorra TV',
|
||||
lang: 'ca',
|
||||
xmltv_id: 'AndorraTV.ad',
|
||||
site_id: 'atv',
|
||||
site: 'andorradifusio.ad',
|
||||
filepath: 'tests/__data__/input/site.channels.xml',
|
||||
cluster_id: 1
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue