mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-10 00:50:09 -04:00
Update update.test.js
This commit is contained in:
parent
93446b219e
commit
b67a942284
1 changed files with 12 additions and 29 deletions
|
@ -6,23 +6,19 @@ const glob = require('glob')
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.copyFileSync(
|
fs.copyFileSync(
|
||||||
'tests/__data__/input/database/update-guides/queue.db',
|
'tests/__data__/input/database/update-guides/programs.db',
|
||||||
'tests/__data__/output/queue.db'
|
'tests/__data__/output/programs.db'
|
||||||
|
)
|
||||||
|
|
||||||
|
const stdout = execSync(
|
||||||
|
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output CURR_DATE=2022-10-20 npm run guides:update',
|
||||||
|
{ encoding: 'utf8' }
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can generate /guides', () => {
|
it('can generate /guides', () => {
|
||||||
fs.copyFileSync(
|
|
||||||
'tests/__data__/input/database/update-guides/programs.db',
|
|
||||||
'tests/__data__/output/programs.db'
|
|
||||||
)
|
|
||||||
const stdout = execSync(
|
|
||||||
'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output CURR_DATE=2022-05-05 npm run guides:update',
|
|
||||||
{ encoding: 'utf8' }
|
|
||||||
)
|
|
||||||
|
|
||||||
const uncompressed = glob
|
const uncompressed = glob
|
||||||
.sync('tests/__data__/expected/guides/**/*.epg.xml')
|
.sync('tests/__data__/expected/guides/*.xml')
|
||||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
uncompressed.forEach(filepath => {
|
uncompressed.forEach(filepath => {
|
||||||
|
@ -30,7 +26,7 @@ it('can generate /guides', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const compressed = glob
|
const compressed = glob
|
||||||
.sync('tests/__data__/expected/guides/**/*.epg.xml.gz')
|
.sync('tests/__data__/expected/guides/*.xml.gz')
|
||||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
compressed.forEach(filepath => {
|
compressed.forEach(filepath => {
|
||||||
|
@ -38,29 +34,16 @@ it('can generate /guides', () => {
|
||||||
})
|
})
|
||||||
|
|
||||||
const json = glob
|
const json = glob
|
||||||
.sync('tests/__data__/expected/guides/**/*.json')
|
.sync('tests/__data__/expected/guides/*.json')
|
||||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||||
|
|
||||||
json.forEach(filepath => {
|
json.forEach(filepath => {
|
||||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||||
})
|
})
|
||||||
})
|
|
||||||
|
|
||||||
it('will terminate process if programs not found', () => {
|
expect(content('output/logs/guides/update.log')).toEqual(
|
||||||
fs.copyFileSync(
|
content('expected/logs/guides/update.log')
|
||||||
'tests/__data__/input/database/update-guides/no-programs.db',
|
|
||||||
'tests/__data__/output/programs.db'
|
|
||||||
)
|
)
|
||||||
try {
|
|
||||||
const stdout = execSync(
|
|
||||||
'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output npm run guides:update',
|
|
||||||
{ encoding: 'utf8' }
|
|
||||||
)
|
|
||||||
process.exit(1)
|
|
||||||
} catch (err) {
|
|
||||||
expect(err.status).toBe(1)
|
|
||||||
expect(err.stdout.includes('Error: No programs found')).toBe(true)
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath) {
|
function content(filepath) {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue