mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 16:40:07 -04:00
Delete extra tests
This commit is contained in:
parent
9cfc51cac3
commit
54923b88fb
6 changed files with 0 additions and 234 deletions
|
@ -1,26 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'LOGS_DIR=tests/__data__/input/logs OUTPUT_DIR=tests/__data__/output/api npm run api:update',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate guides.json', () => {
|
||||
expect(content('tests/__data__/output/api/guides.json')).toBe(
|
||||
content('tests/__data__/expected/api/guides.json')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
|
@ -1,37 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/output/queue.db')
|
||||
})
|
||||
|
||||
it('can load cluster and will terminate process if programs not found', () => {
|
||||
try {
|
||||
execSync(
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs npm run cluster:load -- --cluster-id=1 --timeout=10000',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
process.exit(1)
|
||||
} catch (err) {
|
||||
expect(err.status).toBe(1)
|
||||
expect(err.stdout.includes('Error: No programs found')).toBe(true)
|
||||
expect(content('tests/__data__/output/logs/cluster/load/cluster_1.log')).toEqual(
|
||||
content('tests/__data__/expected/logs/cluster/load/cluster_1.log')
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return data
|
||||
.split('\n')
|
||||
.filter(l => l)
|
||||
.map(l => {
|
||||
return JSON.parse(l)
|
||||
})
|
||||
}
|
|
@ -1,49 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/update-guides/programs.db',
|
||||
'tests/__data__/output/programs.db'
|
||||
)
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/update-guides/queue.db',
|
||||
'tests/__data__/output/queue.db'
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate /guides', () => {
|
||||
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' }
|
||||
)
|
||||
|
||||
const uncompressed = glob
|
||||
.sync('tests/__data__/expected/guides/**/*.xml')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
uncompressed.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
|
||||
const compressed = glob
|
||||
.sync('tests/__data__/expected/guides/**/*.xml.gz')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
compressed.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
|
||||
expect(content('output/logs/guides/update.log')).toEqual(
|
||||
content('expected/logs/guides/update.log')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/output/queue.db')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/input/logs npm run programs:save',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can save programs to database', () => {
|
||||
let output = content('tests/__data__/output/programs.db')
|
||||
let expected = content('tests/__data__/expected/database/programs.db')
|
||||
|
||||
output = output.map(i => {
|
||||
i._id = null
|
||||
return i
|
||||
})
|
||||
expected = expected.map(i => {
|
||||
i._id = null
|
||||
return i
|
||||
})
|
||||
|
||||
expect(output).toEqual(expected)
|
||||
})
|
||||
|
||||
it('can update queue', () => {
|
||||
expect(content('tests/__data__/output/queue.db')).toEqual(
|
||||
content('tests/__data__/expected/database/queue-with-errors.db')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return data
|
||||
.split('\n')
|
||||
.filter(l => l)
|
||||
.map(l => {
|
||||
return JSON.parse(l)
|
||||
})
|
||||
}
|
|
@ -1,48 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output/database CHANNELS_PATH=tests/__data__/input/sites/example.com_*.channels.xml DATA_DIR=tests/__data__/input/data CURR_DATE=2022-12-29 npm run queue:create -- --max-clusters=1',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can create queue', () => {
|
||||
let output = content('tests/__data__/output/database/queue.db')
|
||||
let expected = content('tests/__data__/expected/database/create-queue/queue.db')
|
||||
|
||||
output = output.map(i => {
|
||||
i._id = null
|
||||
return i
|
||||
})
|
||||
expected = expected.map(i => {
|
||||
i._id = null
|
||||
return i
|
||||
})
|
||||
|
||||
expect(output).toEqual(
|
||||
expect.arrayContaining([
|
||||
expect.objectContaining(expected[0]),
|
||||
expect.objectContaining(expected[1]),
|
||||
expect.objectContaining(expected[2]),
|
||||
expect.objectContaining(expected[3])
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return data
|
||||
.split('\n')
|
||||
.filter(l => l)
|
||||
.map(l => {
|
||||
return JSON.parse(l)
|
||||
})
|
||||
}
|
|
@ -1,26 +0,0 @@
|
|||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'LOGS_DIR=tests/__data__/input/logs DATA_DIR=tests/__data__/input/data npm run readme:update -- --config=tests/__data__/input/readme.json',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can update readme.md', () => {
|
||||
expect(content('tests/__data__/output/readme.md')).toBe(
|
||||
content('tests/__data__/expected/_readme.md')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue