mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Update load-cluster.js
This commit is contained in:
parent
b15ed0a4c6
commit
0161ac02d0
3 changed files with 23 additions and 30 deletions
2
tests/__data__/expected/logs/load-cluster/cluster_1.log
Normal file
2
tests/__data__/expected/logs/load-cluster/cluster_1.log
Normal file
|
@ -0,0 +1,2 @@
|
|||
{"channel":{"lang":"fr","xmltv_id":"CNNInternationalEurope.us","site_id":"53","site":"chaines-tv.orange.fr","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["fr/chaines-tv.orange.fr","bh/chaines-tv.orange.fr"],"cluster_id":1,"programCount":32,"_id":"0Wefq0oMR3feCcuY"},"programs":[],"date":"2022-01-29T00:00:00Z","error":null}
|
||||
{"channel":{"lang":"ru","xmltv_id":"CNNInternationalEurope.us","site_id":"140","site":"magticom.ge","configPath":"tests/__data__/input/sites/example.com.config.js","groups":["ge/magticom.ge"],"cluster_id":1,"programCount":0,"_id":"1XzrxNkSF2AQNBrT"},"programs":[],"date":"2022-01-29T00:00:00Z","error":null}
|
|
@ -11,10 +11,7 @@ beforeEach(() => {
|
|||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/temp/database', { recursive: true })
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/channels.db',
|
||||
'tests/__data__/temp/database/channels.db'
|
||||
)
|
||||
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/temp/database/queue.db')
|
||||
|
||||
execSync(
|
||||
'DB_DIR=tests/__data__/temp/database LOGS_DIR=tests/__data__/output/logs node scripts/commands/load-cluster.js --cluster-id=1 --timeout=10000',
|
||||
|
@ -23,25 +20,19 @@ beforeEach(() => {
|
|||
})
|
||||
|
||||
it('can load cluster', () => {
|
||||
const output = content('tests/__data__/output/logs/load-cluster/cluster_1.log')
|
||||
let output = content('tests/__data__/output/logs/load-cluster/cluster_1.log')
|
||||
let expected = content('tests/__data__/expected/logs/load-cluster/cluster_1.log')
|
||||
|
||||
expect(Object.keys(output[0]).sort()).toEqual(['channel', 'date', 'error', 'programs'])
|
||||
|
||||
expect(output[0]).toMatchObject({
|
||||
channel: {
|
||||
_id: '0Wefq0oMR3feCcuY',
|
||||
logo: 'https://example.com/logo.png'
|
||||
},
|
||||
date: dayjs.utc().startOf('d').format(),
|
||||
error: null
|
||||
output = output.map(i => {
|
||||
i.date = null
|
||||
return i
|
||||
})
|
||||
expected = expected.map(i => {
|
||||
i.date = null
|
||||
return i
|
||||
})
|
||||
|
||||
expect(output[1]).toMatchObject({
|
||||
channel: {
|
||||
_id: '1XzrxNkSF2AQNBrT',
|
||||
logo: 'https://www.magticom.ge/images/channels/MjAxOC8wOS8xMC9lZmJhNWU5Yy0yMmNiLTRkMTAtOWY5Ny01ODM0MzY0ZTg0MmEuanBn.jpg'
|
||||
}
|
||||
})
|
||||
expect(output).toEqual(expected)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue