mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -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
6
tests/__data__/input/site.channels.xml
Normal file
6
tests/__data__/input/site.channels.xml
Normal file
|
@ -0,0 +1,6 @@
|
|||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
<site site="andorradifusio.ad">
|
||||
<channels>
|
||||
<channel lang="ca" xmltv_id="AndorraTV.ad" site_id="atv">Andorra TV</channel>
|
||||
</channels>
|
||||
</site>
|
1
tests/__data__/output/test.db
Normal file
1
tests/__data__/output/test.db
Normal file
|
@ -0,0 +1 @@
|
|||
{"lang":"ca","xmltv_id":"AndorraTV.ad","site_id":"atv","name":"Andorra TV","site":"andorradifusio.ad","filepath":"tests/__data__/input/site.channels.xml","cluster_id":1,"_id":"2lf1xEfDjyxPsXhO"}
|
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