mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-11 01:20:08 -04:00
Move scripts to subfolders
This commit is contained in:
parent
f0c64a55e4
commit
b1a0bcf4b9
36 changed files with 204 additions and 222 deletions
|
@ -1,22 +1,20 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'CHANNELS_PATH=tests/__data__/input/sites/**.channels.xml OUTPUT_DIR=tests/__data__/output/api node scripts/commands/update-api.js',
|
||||
'CHANNELS_PATH=tests/__data__/input/sites/**.channels.xml OUTPUT_DIR=tests/__data__/output/api npm run api:update',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate guides.json', () => {
|
||||
const output = content('tests/__data__/output/api/guides.json')
|
||||
const expected = content('tests/__data__/expected/api/guides.json')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
expect(content('tests/__data__/output/api/guides.json')).toBe(
|
||||
content('tests/__data__/expected/api/guides.json')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
32
tests/commands/cluster/load.test.js
Normal file
32
tests/commands/cluster/load.test.js
Normal file
|
@ -0,0 +1,32 @@
|
|||
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')
|
||||
|
||||
execSync(
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs npm run cluster:load -- --cluster-id=1 --timeout=10000',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can load cluster', () => {
|
||||
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,25 +0,0 @@
|
|||
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.mkdirSync('tests/__data__/temp/database', { recursive: true })
|
||||
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/temp/database/queue.db')
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
||||
})
|
||||
|
||||
it('can create valid matrix', () => {
|
||||
const result = execSync(
|
||||
'DB_DIR=tests/__data__/temp/database node scripts/commands/create-matrix.js',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
|
||||
expect(result).toBe('::set-output name=matrix::{"cluster_id":[1,4,84,120]}\n')
|
||||
})
|
38
tests/commands/guides/update.test.js
Normal file
38
tests/commands/guides/update.test.js
Normal file
|
@ -0,0 +1,38 @@
|
|||
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')
|
||||
fs.copyFileSync('tests/__data__/input/database/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 LOGS_DIR=tests/__data__/output/logs npm run guides:update',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate /guides', () => {
|
||||
expect(content('tests/__data__/output/guides/fr/chaines-tv.orange.fr.epg.xml')).toBe(
|
||||
content('tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.xml')
|
||||
)
|
||||
|
||||
expect(content('tests/__data__/output/guides/zw/dstv.com.epg.xml')).toBe(
|
||||
content('tests/__data__/expected/guides/zw/dstv.com.epg.xml')
|
||||
)
|
||||
})
|
||||
|
||||
it('can create guides.log', () => {
|
||||
expect(content('tests/__data__/output/logs/guides/update.log')).toBe(
|
||||
content('tests/__data__/expected/logs/guides/update.log')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
|
@ -1,40 +0,0 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const dayjs = require('dayjs')
|
||||
const utc = require('dayjs/plugin/utc')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
dayjs.extend(utc)
|
||||
|
||||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
||||
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/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',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can load cluster', () => {
|
||||
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(output).toEqual(expected)
|
||||
})
|
||||
|
||||
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,25 +1,19 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/output/database', { recursive: true })
|
||||
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/queue.db',
|
||||
'tests/__data__/output/database/queue.db'
|
||||
)
|
||||
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/database LOGS_DIR=tests/__data__/input/logs node scripts/commands/save-results.js',
|
||||
'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/database/programs.db')
|
||||
let output = content('tests/__data__/output/programs.db')
|
||||
let expected = content('tests/__data__/expected/database/programs.db')
|
||||
|
||||
output = output.map(i => {
|
||||
|
@ -35,10 +29,9 @@ it('can save programs to database', () => {
|
|||
})
|
||||
|
||||
it('can update queue', () => {
|
||||
const output = content('tests/__data__/output/database/queue.db')
|
||||
const expected = content('tests/__data__/expected/database/queue-with-errors.db')
|
||||
|
||||
expect(output).toEqual(expected)
|
||||
expect(content('tests/__data__/output/queue.db')).toEqual(
|
||||
content('tests/__data__/expected/database/queue-with-errors.db')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
|
@ -1,13 +1,12 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/output/logs CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml node scripts/commands/create-queue.js --max-clusters=1 --days=2',
|
||||
'DB_DIR=tests/__data__/output/database LOGS_DIR=tests/__data__/output/logs CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml npm run queue:create -- --max-clusters=1 --days=2',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
@ -35,13 +34,6 @@ it('can create queue', () => {
|
|||
)
|
||||
})
|
||||
|
||||
it('can log errors', () => {
|
||||
let output = content('tests/__data__/output/logs/errors/ca/example.com.log')
|
||||
let expected = content('tests/__data__/expected/logs/errors/ca/example.com.log')
|
||||
|
||||
expect(output).toEqual(expected)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
|
@ -1,22 +1,20 @@
|
|||
const fs = require('fs')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.rmdirSync('tests/__data__/output', { recursive: true })
|
||||
fs.mkdirSync('tests/__data__/output')
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml DATA_DIR=tests/__data__/input/data node scripts/commands/update-readme.js --config=tests/__data__/input/_readme.json',
|
||||
'CHANNELS_PATH=tests/__data__/input/sites/*.channels.xml DATA_DIR=tests/__data__/input/data npm run readme:update -- --config=tests/__data__/input/readme.json',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can update readme.md', () => {
|
||||
const output = content('tests/__data__/output/readme.md')
|
||||
const expected = content('tests/__data__/expected/readme.md')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
expect(content('tests/__data__/output/readme.md')).toBe(
|
||||
content('tests/__data__/expected/_readme.md')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
|
@ -1,67 +0,0 @@
|
|||
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.mkdirSync('tests/__data__/temp/database', { recursive: true })
|
||||
fs.copyFileSync('tests/__data__/input/database/queue.db', 'tests/__data__/temp/database/queue.db')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/programs.db',
|
||||
'tests/__data__/temp/database/programs.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/temp/database DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs node scripts/commands/update-guides.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
afterEach(() => {
|
||||
fs.rmdirSync('tests/__data__/temp', { recursive: true })
|
||||
})
|
||||
|
||||
it('can generate /guides', () => {
|
||||
const output1 = content('tests/__data__/output/guides/fr/chaines-tv.orange.fr.epg.xml')
|
||||
const expected1 = content('tests/__data__/expected/guides/fr/chaines-tv.orange.fr.epg.xml')
|
||||
|
||||
expect(output1).toBe(expected1)
|
||||
|
||||
const output2 = content('tests/__data__/output/guides/zw/dstv.com.epg.xml')
|
||||
const expected2 = content('tests/__data__/expected/guides/zw/dstv.com.epg.xml')
|
||||
|
||||
expect(output2).toBe(expected2)
|
||||
})
|
||||
|
||||
it('can create guides.log', () => {
|
||||
const output = content('tests/__data__/output/logs/guides.log')
|
||||
const expected = content('tests/__data__/expected/logs/guides.log')
|
||||
|
||||
expect(output).toBe(expected)
|
||||
})
|
||||
|
||||
it('can log errors', () => {
|
||||
const output1 = content('tests/__data__/output/logs/errors/ru/yandex.ru.log')
|
||||
const expected1 = content('tests/__data__/expected/logs/errors/ru/yandex.ru.log')
|
||||
|
||||
expect(output1).toBe(expected1)
|
||||
|
||||
const output2 = content('tests/__data__/output/logs/errors/us/directv.com.log')
|
||||
const expected2 = content('tests/__data__/expected/logs/errors/us/directv.com.log')
|
||||
|
||||
expect(output2).toBe(expected2)
|
||||
|
||||
const output3 = content('tests/__data__/output/logs/errors/ge/magticom.ge.log')
|
||||
const expected3 = content('tests/__data__/expected/logs/errors/ge/magticom.ge.log')
|
||||
|
||||
expect(output3).toBe(expected3)
|
||||
})
|
||||
|
||||
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