mirror of
https://github.com/iptv-org/iptv
synced 2026-04-25 04:07:20 -04:00
Create subfolders for commands
This commit is contained in:
@@ -1,37 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/cleanup-database.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output node scripts/commands/cleanup-database.js',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
})
|
||||
|
||||
it('can remove broken links from database', () => {
|
||||
expect(content('tests/__data__/output/streams.db')).toEqual(
|
||||
content('tests/__data__/expected/database/cleanup-database.streams.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,47 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output/database node scripts/commands/create-database.js --input-dir=tests/__data__/input/channels --max-clusters=1',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can create database', () => {
|
||||
let output = content('tests/__data__/output/database/streams.db')
|
||||
let expected = content('tests/__data__/expected/database/streams.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])
|
||||
])
|
||||
)
|
||||
})
|
||||
|
||||
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,16 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/output/streams.db')
|
||||
})
|
||||
|
||||
it('can create valid matrix', () => {
|
||||
const result = execSync('DB_DIR=tests/__data__/output node scripts/commands/create-matrix.js', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
expect(result).toBe('::set-output name=matrix::{"cluster_id":[1,3]}\n')
|
||||
})
|
||||
@@ -1,37 +1,35 @@
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const glob = require('glob')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/generate-playlists.streams.db',
|
||||
'tests/__data__/input/database/playlist-generate.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs/generators node --trace-warnings scripts/commands/generate-playlists.js',
|
||||
'DB_DIR=tests/__data__/output DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs/generators node --trace-warnings scripts/commands/playlist/generate.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can generate playlists', () => {
|
||||
const files = glob
|
||||
it('can generate playlists and logs', () => {
|
||||
const playlists = glob
|
||||
.sync('tests/__data__/expected/.gh-pages/**/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
playlists.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
it('can generate logs', () => {
|
||||
const files = glob
|
||||
const logs = glob
|
||||
.sync('tests/__data__/expected/logs/generators/*.log')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
logs.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
@@ -7,12 +7,9 @@ beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/output/streams.db')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output node scripts/commands/update-playlists.js',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
const stdout = execSync('DB_DIR=tests/__data__/output node scripts/commands/playlist/update.js', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can update playlists', () => {
|
||||
@@ -2,9 +2,12 @@ const { execSync } = require('child_process')
|
||||
|
||||
it('show error if channel name in the blocklist', () => {
|
||||
try {
|
||||
execSync('node scripts/commands/validate.js tests/__data__/input/channels/us_blocked.m3u', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
execSync(
|
||||
'DATA_DIR=tests/__data__/input/data node scripts/commands/playlist/validate.js tests/__data__/input/channels/us_blocked.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
} catch (err) {
|
||||
expect(err.status).toBe(1)
|
||||
expect(err.stdout).toBe(
|
||||
@@ -15,7 +18,7 @@ it('show error if channel name in the blocklist', () => {
|
||||
|
||||
it('show warning if channel has wrong id', () => {
|
||||
const stdout = execSync(
|
||||
'node scripts/commands/validate.js tests/__data__/input/channels/wrong_id.m3u',
|
||||
'DATA_DIR=tests/__data__/input/data node scripts/commands/playlist/validate.js tests/__data__/input/channels/wrong_id.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
@@ -1,12 +1,12 @@
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs/generators node scripts/commands/update-readme.js --config=tests/__data__/input/_readme.json',
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs/generators node scripts/commands/readme/update.js --config=tests/__data__/input/_readme.json',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
@@ -1,35 +0,0 @@
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/save-results.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/input/logs/load-cluster node scripts/commands/save-results.js',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can save results', () => {
|
||||
expect(content('tests/__data__/output/streams.db')).toEqual(
|
||||
content('tests/__data__/expected/database/save-results.streams.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,20 +1,20 @@
|
||||
const { execSync } = require('child_process')
|
||||
const fs = require('fs-extra')
|
||||
const path = require('path')
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync('tests/__data__/input/database/streams.db', 'tests/__data__/output/streams.db')
|
||||
|
||||
const stdout = execSync(
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs/load-cluster node scripts/commands/load-cluster.js --cluster-id=1 --timeout=1',
|
||||
'DB_DIR=tests/__data__/output LOGS_DIR=tests/__data__/output/logs/stream/load node scripts/commands/stream/load.js --cluster-id=1 --timeout=1',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('return results', () => {
|
||||
expect(content('tests/__data__/output/logs/load-cluster/cluster_1.log')).toEqual(
|
||||
content('tests/__data__/expected/logs/load-cluster/cluster_1.log')
|
||||
expect(content('tests/__data__/output/logs/stream/load/cluster_1.log')).toEqual(
|
||||
content('tests/__data__/expected/logs/stream/load/cluster_1.log')
|
||||
)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user