mirror of
https://github.com/iptv-org/iptv
synced 2025-12-16 10:26:48 -05:00
Update tests
This commit is contained in:
@@ -39,5 +39,4 @@ function checkStdout(stdout: string) {
|
|||||||
expect(stdout).toContain('TF1.fr (TF1, Télévision française 1)')
|
expect(stdout).toContain('TF1.fr (TF1, Télévision française 1)')
|
||||||
expect(stdout).toContain('Type...')
|
expect(stdout).toContain('Type...')
|
||||||
expect(stdout).toContain('Skip')
|
expect(stdout).toContain('Skip')
|
||||||
expect(stdout).toContain("File 'tests/__data__/output/playlist.m3u' successfully saved")
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
|
import os, { EOL } from 'node:os'
|
||||||
import * as fs from 'fs-extra'
|
import * as fs from 'fs-extra'
|
||||||
import * as glob from 'glob'
|
import * as glob from 'glob'
|
||||||
import os from 'os'
|
|
||||||
|
|
||||||
let ENV_VAR =
|
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'
|
'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'
|
||||||
@@ -36,8 +36,8 @@ describe('playlist:generate', () => {
|
|||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
expect(content('tests/__data__/output/logs/generators.log').split('\n').sort()).toStrictEqual(
|
expect(content('tests/__data__/output/logs/generators.log').split(EOL).sort()).toStrictEqual(
|
||||||
content('tests/__data__/expected/playlist_generate/logs/generators.log').split('\n').sort()
|
content('tests/__data__/expected/playlist_generate/logs/generators.log').split(EOL).sort()
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
import path from 'node:path'
|
import path from 'node:path'
|
||||||
import os from 'os'
|
import os from 'node:os'
|
||||||
|
|
||||||
type ExecError = {
|
type ExecError = {
|
||||||
status: number
|
status: number
|
||||||
@@ -16,22 +16,15 @@ describe('playlist:test', () => {
|
|||||||
it('shows an error if the playlist contains a broken link', () => {
|
it('shows an error if the playlist contains a broken link', () => {
|
||||||
const cmd = `${ENV_VAR} npm run playlist:test playlist_test/ag.m3u`
|
const cmd = `${ENV_VAR} npm run playlist:test playlist_test/ag.m3u`
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
checkStdout(stdout)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// NOTE: for Windows only
|
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||||
checkStdout((error as ExecError).stdout)
|
expect((error as ExecError).stdout).toContain(slash('playlist_test/ag.m3u'))
|
||||||
|
expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function checkStdout(stdout: string) {
|
|
||||||
expect(stdout).toContain(slash('playlist_test/ag.m3u'))
|
|
||||||
expect(stdout).toContain('2 problems (1 errors, 1 warnings)')
|
|
||||||
}
|
|
||||||
|
|
||||||
function slash(filepath: string) {
|
function slash(filepath: string) {
|
||||||
return filepath.split(path.sep).join(path.posix.sep)
|
return filepath.split(path.sep).join(path.posix.sep)
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,31 +17,29 @@ describe('playlist:validate', () => {
|
|||||||
it('show an error if channel id in the blocklist', () => {
|
it('show an error if channel id in the blocklist', () => {
|
||||||
const cmd = `${ENV_VAR} npm run playlist:validate -- us_blocked.m3u`
|
const cmd = `${ENV_VAR} npm run playlist:validate -- us_blocked.m3u`
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
checkStdout(stdout)
|
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// NOTE: for Windows only
|
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||||
checkStdout((error as ExecError).stdout)
|
expect((error as ExecError).stdout).toContain('us_blocked.m3u')
|
||||||
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
'2 error "FoxSports2.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002)'
|
||||||
|
)
|
||||||
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
'4 error "TVN.pl" is on the blocklist due to NSFW content (https://github.com/iptv-org/iptv/issues/0003)'
|
||||||
|
)
|
||||||
|
expect((error as ExecError).stdout).toContain('2 problems (2 errors, 0 warnings)')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('show a warning if channel has wrong id', () => {
|
it('show a warning if channel has wrong id', () => {
|
||||||
const cmd = `${ENV_VAR} npm run playlist:validate -- wrong_id.m3u`
|
const cmd = `${ENV_VAR} npm run playlist:validate -- wrong_id.m3u`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
try {
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
execSync(cmd, { encoding: 'utf8' })
|
||||||
|
} catch (error) {
|
||||||
expect(stdout).toContain(
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||||
'wrong_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n'
|
expect((error as ExecError).stdout).toContain(
|
||||||
)
|
'wrong_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n'
|
||||||
|
)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function checkStdout(stdout: string) {
|
|
||||||
expect(stdout).toContain(`us_blocked.m3u
|
|
||||||
2 error "FoxSports2.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002)
|
|
||||||
4 error "TVN.pl" is on the blocklist due to NSFW content (https://github.com/iptv-org/iptv/issues/0003)
|
|
||||||
|
|
||||||
2 problems (2 errors, 0 warnings)`)
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user