mirror of https://github.com/iptv-org/iptv
Update tests
parent
708744b28f
commit
8a83f23243
@ -1,32 +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/playlist_format.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
|
||||
const stdout = execSync('DB_DIR=tests/__data__/output npm run playlist:format', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
})
|
||||
|
||||
it('can format playlists', () => {
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/streams/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
@ -0,0 +1,36 @@
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import { glob } from 'glob'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/database/playlist_update.streams.db',
|
||||
'tests/__data__/output/streams.db'
|
||||
)
|
||||
})
|
||||
|
||||
it('can format playlists', () => {
|
||||
const stdout = execSync(
|
||||
'DEBUG=true DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/output/streams DB_DIR=tests/__data__/output npm run playlist:update --silent',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
|
||||
expect(stdout).toBe(`OUTPUT=closes #14151, closes #14110, closes #14179, closes #14178\n`)
|
||||
|
||||
const files = glob
|
||||
.sync('tests/__data__/expected/streams/*.m3u')
|
||||
.map(f => f.replace('tests/__data__/expected/', ''))
|
||||
|
||||
files.forEach(filepath => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
@ -1,32 +0,0 @@
|
||||
const { execSync } = require('child_process')
|
||||
|
||||
it('show an error if channel name in the blocklist', () => {
|
||||
try {
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data npm run playlist:validate -- tests/__data__/input/streams/us_blocked.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (err) {
|
||||
expect(err.status).toBe(1)
|
||||
expect(err.stdout).toBe(
|
||||
`\n> playlist:validate\n> node scripts/commands/playlist/validate.js tests/__data__/input/streams/us_blocked.m3u\n\nloading blocklist...\nfound 4 records\n\ntests/__data__/input/streams/us_blocked.m3u\n 2 error "Fox Sports 2 Asia" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0000)\n\n1 problems (1 errors, 0 warnings)\n`
|
||||
)
|
||||
}
|
||||
})
|
||||
|
||||
it('show a warning if channel has wrong id', () => {
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data npm run playlist:validate -- tests/__data__/input/streams/wrong_id.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
|
||||
expect(stdout).toBe(
|
||||
`\n> playlist:validate\n> node scripts/commands/playlist/validate.js tests/__data__/input/streams/wrong_id.m3u\n\nloading blocklist...\nfound 4 records\n\ntests/__data__/input/streams/wrong_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n`
|
||||
)
|
||||
})
|
@ -0,0 +1,36 @@
|
||||
import { execSync } from 'child_process'
|
||||
|
||||
it('show an error if channel name in the blocklist', () => {
|
||||
try {
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams npm run playlist:validate -- tests/__data__/input/streams/us_blocked.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error: any) {
|
||||
expect(error.status).toBe(1)
|
||||
expect(
|
||||
error.stdout.includes(
|
||||
`loading blocklist...\nfound 4 records\n\ntests/__data__/input/streams/us_blocked.m3u\n 2 error "Fox Sports 2 Asia (Thai)" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0000)\n\n1 problems (1 errors, 0 warnings)\n`
|
||||
)
|
||||
).toBe(true)
|
||||
}
|
||||
})
|
||||
|
||||
it('show a warning if channel has wrong id', () => {
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams npm run playlist:validate -- tests/__data__/input/streams/wrong_id.m3u',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
|
||||
expect(
|
||||
stdout.includes(
|
||||
`loading blocklist...\nfound 4 records\n\ntests/__data__/input/streams/wrong_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n`
|
||||
)
|
||||
).toBe(true)
|
||||
})
|
@ -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(
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs/generators npm run readme:update -- --config=tests/__data__/input/_readme.json',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can update readme.md', () => {
|
||||
expect(content('tests/__data__/output/readme.md')).toEqual(
|
||||
content('tests/__data__/expected/_readme.md')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
@ -0,0 +1,35 @@
|
||||
import { execSync } from 'child_process'
|
||||
import fs from 'fs-extra'
|
||||
import path from 'path'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
fs.mkdirSync('tests/__data__/output/.readme')
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/.readme/config.json',
|
||||
'tests/__data__/output/.readme/config.json'
|
||||
)
|
||||
fs.copyFileSync(
|
||||
'tests/__data__/input/.readme/template.md',
|
||||
'tests/__data__/output/.readme/template.md'
|
||||
)
|
||||
|
||||
const stdout = execSync(
|
||||
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs README_DIR=tests/__data__/output/.readme npm run readme:update',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
})
|
||||
|
||||
it('can update readme.md', () => {
|
||||
expect(content('tests/__data__/output/readme.md')).toEqual(
|
||||
content('tests/__data__/expected/_readme.md')
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
const data = fs.readFileSync(path.resolve(filepath), {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
return JSON.stringify(data)
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
import { execSync } from 'child_process'
|
||||
|
||||
it('can create report', () => {
|
||||
const stdout = execSync('DATA_DIR=tests/__data__/input/data npm run report:create', {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
|
||||
expect(
|
||||
stdout.includes(`
|
||||
┌─────────┬─────────────┬───────────────────┬──────────────┐
|
||||
│ (index) │ issueNumber │ channelId │ status │
|
||||
├─────────┼─────────────┼───────────────────┼──────────────┤
|
||||
│ 0 │ 14179 │ 'ManoramaNews.in' │ 'pending' │
|
||||
│ 1 │ 14178 │ 'TV3.my' │ 'blocked' │
|
||||
│ 2 │ 14177 │ 'TUTV.us' │ 'fullfilled' │
|
||||
│ 3 │ 14176 │ 'ManoramaNews.in' │ 'duplicate' │
|
||||
│ 4 │ 14175 │ 'TFX.fr' │ 'invalid_id' │
|
||||
└─────────┴─────────────┴───────────────────┴──────────────┘`)
|
||||
).toBe(true)
|
||||
})
|
Loading…
Reference in New Issue