mirror of
https://github.com/iptv-org/epg.git
synced 2025-05-09 08:30:06 -04:00
Add "debug" mode to tests
This commit is contained in:
parent
ae7b32b079
commit
c8055f10d6
7 changed files with 31 additions and 27 deletions
|
@ -16,7 +16,8 @@ beforeEach(() => {
|
|||
describe('api:generate', () => {
|
||||
it('can generate guides.json', () => {
|
||||
const cmd = `${ENV_VAR} npm run api:generate`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guides.json')).toEqual(
|
||||
content('tests/__data__/expected/guides.json')
|
||||
|
|
|
@ -25,7 +25,8 @@ describe('channels:editor', () => {
|
|||
|
||||
try {
|
||||
const cmd = `${ENV_VAR} npm run channels:editor --- tests/__data__/output/channels.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
expect((error as ExecError).stdout).toContain('CNN International | CNNInternational.us [new]')
|
||||
|
|
|
@ -9,7 +9,8 @@ describe('channels:lint', () => {
|
|||
it('will show a message if the file contains a syntax error', () => {
|
||||
try {
|
||||
const cmd = 'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml'
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
|
@ -23,7 +24,8 @@ describe('channels:lint', () => {
|
|||
try {
|
||||
const cmd =
|
||||
'npm run channels:lint --- tests/__data__/input/channels-lint/invalid.channels.xml'
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
|
@ -37,7 +39,8 @@ describe('channels:lint', () => {
|
|||
try {
|
||||
const cmd =
|
||||
'npm run channels:lint --- tests/__data__/input/channels-lint/error.channels.xml tests/__data__/input/channels-lint/invalid.channels.xml'
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
|
|
|
@ -14,7 +14,8 @@ describe('channels:parse', () => {
|
|||
it('can parse channels', () => {
|
||||
const cmd =
|
||||
'npm run channels:parse --- --config=tests/__data__/input/channels-parse/channels-parse.config.js --output=tests/__data__/output/channels.xml'
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/channels.xml')).toEqual(
|
||||
content('tests/__data__/expected/sites/channels-parse/channels-parse.channels.xml')
|
||||
|
|
|
@ -15,17 +15,12 @@ describe('channels:validate', () => {
|
|||
it('will show a message if the file contains a duplicate', () => {
|
||||
try {
|
||||
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/duplicate.channels.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
expect((error as ExecError).stdout).toContain(`
|
||||
> channels:validate
|
||||
> npx tsx scripts/commands/channels/validate.ts --channels=tests/__data__/input/channels-validate/duplicate.channels.xml
|
||||
|
||||
options:
|
||||
channels: tests/__data__/input/channels-validate/duplicate.channels.xml
|
||||
tests/__data__/input/channels-validate/duplicate.channels.xml
|
||||
┌─────────┬─────────────┬──────┬────────────────┬─────────┬─────────┐
|
||||
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
||||
├─────────┼─────────────┼──────┼────────────────┼─────────┼─────────┤
|
||||
|
@ -40,17 +35,12 @@ tests/__data__/input/channels-validate/duplicate.channels.xml
|
|||
it('will show a message if the file contains a channel with wrong xmltv_id', () => {
|
||||
try {
|
||||
const cmd = `${ENV_VAR} npm run channels:validate --- --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
process.exit(1)
|
||||
} catch (error) {
|
||||
expect((error as ExecError).status).toBe(1)
|
||||
expect((error as ExecError).stdout).toContain(`
|
||||
> channels:validate
|
||||
> npx tsx scripts/commands/channels/validate.ts --channels=tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml
|
||||
|
||||
options:
|
||||
channels: tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml
|
||||
tests/__data__/input/channels-validate/wrong_xmltv_id.channels.xml
|
||||
┌─────────┬──────────────────┬──────┬────────────────────┬─────────┬─────────────────────┐
|
||||
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
||||
├─────────┼──────────────────┼──────┼────────────────────┼─────────┼─────────────────────┤
|
||||
|
|
|
@ -20,7 +20,8 @@ describe('epg:grab', () => {
|
|||
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --output=${path.resolve(
|
||||
'tests/__data__/output/guide.xml'
|
||||
)}`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
||||
content('tests/__data__/expected/guide2.xml')
|
||||
|
@ -29,7 +30,8 @@ describe('epg:grab', () => {
|
|||
|
||||
it('can grab epg with multiple channels.xml files', () => {
|
||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/sites/**/*.channels.xml --output=tests/__data__/output/guide.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
||||
content('tests/__data__/expected/guide.xml')
|
||||
|
@ -40,7 +42,8 @@ describe('epg:grab', () => {
|
|||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/sites/**/*.channels.xml --output=${path.resolve(
|
||||
'tests/__data__/output/guide.xml'
|
||||
)} --gzip`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
||||
content('tests/__data__/expected/guide.xml')
|
||||
|
@ -54,7 +57,8 @@ describe('epg:grab', () => {
|
|||
|
||||
it('can grab epg with wildcard as output', () => {
|
||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/sites/example.com/example.com.channels.xml --output=tests/__data__/output/guides/{lang}/{site}.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guides/en/example.com.xml')).toEqual(
|
||||
content('tests/__data__/expected/guides/en/example.com.xml')
|
||||
|
@ -67,7 +71,8 @@ describe('epg:grab', () => {
|
|||
|
||||
it('can grab epg then language filter enabled', () => {
|
||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/sites/example.com/example.com.channels.xml --output=tests/__data__/output/guides/{lang}/{site}.xml --lang=fr`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guides/fr/example.com.xml')).toEqual(
|
||||
content('tests/__data__/expected/guides/fr/example.com.xml')
|
||||
|
@ -76,7 +81,8 @@ describe('epg:grab', () => {
|
|||
|
||||
it('can grab epg using custom channels list', () => {
|
||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/custom.channels.xml --output=tests/__data__/output/guide.xml`
|
||||
execSync(cmd, { encoding: 'utf8' })
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
||||
content('tests/__data__/expected/guide.xml')
|
||||
|
@ -86,6 +92,7 @@ describe('epg:grab', () => {
|
|||
it('it will raise an error if the timeout is exceeded', () => {
|
||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg-grab/custom.channels.xml --output=tests/__data__/output/guide.xml --timeout=0`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(stdout).toContain('ERR: Connection timeout')
|
||||
})
|
||||
|
|
|
@ -16,12 +16,13 @@ beforeEach(() => {
|
|||
})
|
||||
|
||||
it('can update SITES.md', () => {
|
||||
execSync(
|
||||
const stdout = execSync(
|
||||
'DOT_SITES_DIR=tests/__data__/output/.sites SITES_DIR=tests/__data__/input/sites-update/sites npm run sites:update',
|
||||
{
|
||||
encoding: 'utf8'
|
||||
}
|
||||
)
|
||||
if (process.env.DEBUG === 'true') console.log(stdout)
|
||||
|
||||
expect(content('tests/__data__/output/sites.md')).toEqual(
|
||||
content('tests/__data__/expected/_sites.md')
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue