mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Create commands/load-cluster.js
This commit is contained in:
parent
f5dbc9376e
commit
a1f0bc2d2a
10 changed files with 29683 additions and 29503 deletions
|
@ -23,7 +23,8 @@ it('can create database', () => {
|
|||
xmltv_id: 'AndorraTV.ad',
|
||||
site_id: 'atv',
|
||||
site: 'andorradifusio.ad',
|
||||
filepath: 'tests/__data__/input/site.channels.xml',
|
||||
channelsPath: 'tests/__data__/input/site.channels.xml',
|
||||
configPath: 'tests/__data__/input/andorradifusio.ad.config.js',
|
||||
cluster_id: 1
|
||||
})
|
||||
})
|
||||
|
|
36
tests/commands/load-cluster.test.js
Normal file
36
tests/commands/load-cluster.test.js
Normal file
|
@ -0,0 +1,36 @@
|
|||
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')
|
||||
fs.copyFileSync('tests/__data__/input/test.db', 'tests/__data__/temp/test.db')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/temp')
|
||||
})
|
||||
|
||||
it('can load cluster', () => {
|
||||
const result = execSync(
|
||||
'DB_FILEPATH=tests/__data__/temp/test.db LOGS_PATH=tests/__data__/output/logs node scripts/commands/load-cluster.js --cluster-id=1',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
const logs = fs.readFileSync(
|
||||
path.resolve('tests/__data__/output/logs/load-cluster/cluster_1.log'),
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
const lines = logs.split('\n')
|
||||
const parsed = JSON.parse(lines[0])
|
||||
expect(parsed['K1kaxwsWVjsRIZL6'][0]).toMatchObject({
|
||||
title: 'InfoNeu ',
|
||||
start: '2022-01-06T07:00:00.000Z',
|
||||
stop: '2022-01-06T08:00:00.000Z',
|
||||
channel: 'AndorraTV.ad',
|
||||
lang: 'ca'
|
||||
})
|
||||
})
|
Loading…
Add table
Add a link
Reference in a new issue