mirror of
https://github.com/iptv-org/iptv
synced 2026-04-30 14:47:03 -04:00
Update tests
This commit is contained in:
@@ -1,32 +1,39 @@
|
||||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import * as glob from 'glob'
|
||||
import os from 'os'
|
||||
|
||||
let ENV_VAR =
|
||||
'STREAMS_DIR=tests/__data__/input/playlist_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR =
|
||||
'SET "STREAMS_DIR=tests/__data__/input/playlist_generate" && SET "DATA_DIR=tests/__data__/input/data" && SET "PUBLIC_DIR=tests/__data__/output/.gh-pages" && SET "LOGS_DIR=tests/__data__/output/logs" &&'
|
||||
}
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
})
|
||||
|
||||
it('can generate playlists and logs', () => {
|
||||
const stdout = execSync(
|
||||
'STREAMS_DIR=tests/__data__/input/playlist_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate',
|
||||
{ encoding: 'utf8' }
|
||||
)
|
||||
describe('playlist:generate', () => {
|
||||
it('can generate playlists and logs', () => {
|
||||
const cmd = `${ENV_VAR} npm run playlist:generate`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
const playlists = glob
|
||||
.sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u')
|
||||
.map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', ''))
|
||||
|
||||
const playlists = glob
|
||||
.sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u')
|
||||
.map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', ''))
|
||||
playlists.forEach((filepath: string) => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_generate/${filepath}`)
|
||||
)
|
||||
})
|
||||
|
||||
playlists.forEach((filepath: string) => {
|
||||
expect(content(`output/${filepath}`), filepath).toBe(
|
||||
content(`expected/playlist_generate/${filepath}`)
|
||||
expect(content('output/logs/generators.log').split('\n').sort()).toStrictEqual(
|
||||
content('expected/playlist_generate/logs/generators.log').split('\n').sort()
|
||||
)
|
||||
})
|
||||
|
||||
expect(content('output/logs/generators.log').split('\n').sort()).toStrictEqual(
|
||||
content('expected/playlist_generate/logs/generators.log').split('\n').sort()
|
||||
)
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
|
||||
Reference in New Issue
Block a user