mirror of
https://github.com/iptv-org/epg
synced 2025-12-17 10:56:57 -05:00
Update tests
This commit is contained in:
@@ -1,36 +1,36 @@
|
|||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
import fs from 'fs-extra'
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/__data__'
|
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/data'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.copySync(
|
fs.copySync(
|
||||||
'tests/__data__/input/channels_edit/example.com.channels.xml',
|
'tests/__data__/input/channels_edit/example.com.channels.xml',
|
||||||
'tests/__data__/output/channels.xml'
|
'tests/__data__/output/channels.xml'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('channels:edit', () => {
|
describe('channels:edit', () => {
|
||||||
it('shows list of options for a channel', () => {
|
it('shows list of options for a channel', () => {
|
||||||
const cmd = `${ENV_VAR} npm run channels:edit --- tests/__data__/output/channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:edit --- tests/__data__/output/channels.xml`
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
checkStdout(stdout)
|
checkStdout(stdout)
|
||||||
} catch (error: unknown) {
|
} catch (error: unknown) {
|
||||||
// NOTE: for Windows only
|
// NOTE: for Windows only
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
if (process.env.DEBUG === 'true') console.log(cmd, error)
|
||||||
if (error && typeof error === 'object' && 'stdout' in error) {
|
if (error && typeof error === 'object' && 'stdout' in error) {
|
||||||
checkStdout(error.stdout as string)
|
checkStdout(error.stdout as string)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
function checkStdout(stdout: string) {
|
function checkStdout(stdout: string) {
|
||||||
expect(stdout).toContain('CNNInternational.us (CNN International, CNN, CNN Int)')
|
expect(stdout).toContain('CNNInternational.us (CNN International, CNN, CNN Int)')
|
||||||
expect(stdout).toContain('Type...')
|
expect(stdout).toContain('Type...')
|
||||||
expect(stdout).toContain('Skip')
|
expect(stdout).toContain('Skip')
|
||||||
expect(stdout).toContain("File 'tests/__data__/output/channels.xml' successfully saved")
|
expect(stdout).toContain("File 'tests/__data__/output/channels.xml' successfully saved")
|
||||||
}
|
}
|
||||||
|
|||||||
29
tests/commands/channels/format.test.ts
Normal file
29
tests/commands/channels/format.test.ts
Normal file
@@ -0,0 +1,29 @@
|
|||||||
|
import { execSync } from 'child_process'
|
||||||
|
import { pathToFileURL } from 'node:url'
|
||||||
|
import fs from 'fs-extra'
|
||||||
|
|
||||||
|
beforeEach(() => {
|
||||||
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
|
fs.copySync(
|
||||||
|
'tests/__data__/input/channels_format/example.com.channels.xml',
|
||||||
|
'tests/__data__/output/example.com.channels.xml'
|
||||||
|
)
|
||||||
|
})
|
||||||
|
|
||||||
|
describe('channels:format', () => {
|
||||||
|
it('can format *.channels.xml files', () => {
|
||||||
|
const cmd = 'npm run channels:format --- tests/__data__/output/example.com.channels.xml'
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
|
expect(content('tests/__data__/output/example.com.channels.xml')).toEqual(
|
||||||
|
content('tests/__data__/expected/channels_format/example.com.channels.xml')
|
||||||
|
)
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
function content(filepath: string) {
|
||||||
|
return fs.readFileSync(pathToFileURL(filepath), {
|
||||||
|
encoding: 'utf8'
|
||||||
|
})
|
||||||
|
}
|
||||||
@@ -1,58 +1,58 @@
|
|||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
|
|
||||||
interface ExecError {
|
interface ExecError {
|
||||||
status: number
|
status: number
|
||||||
stdout: string
|
stdout: string
|
||||||
}
|
}
|
||||||
|
|
||||||
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/__data__'
|
const ENV_VAR = 'cross-env DATA_DIR=tests/__data__/input/data'
|
||||||
|
|
||||||
describe('channels:validate', () => {
|
describe('channels:validate', () => {
|
||||||
it('will show a message if the file contains a duplicate', () => {
|
it('will show a message if the file contains a duplicate', () => {
|
||||||
try {
|
try {
|
||||||
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/duplicate.channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/duplicate.channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
process.exit(1)
|
process.exit(1)
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
expect((error as ExecError).status).toBe(1)
|
expect((error as ExecError).status).toBe(1)
|
||||||
expect((error as ExecError).stdout).toContain(`
|
expect((error as ExecError).stdout).toContain(`
|
||||||
┌─────────┬─────────────┬──────┬─────────────────┬─────────┬─────────┐
|
┌─────────┬─────────────┬──────┬─────────────────┬─────────┬─────────┐
|
||||||
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
||||||
├─────────┼─────────────┼──────┼─────────────────┼─────────┼─────────┤
|
├─────────┼─────────────┼──────┼─────────────────┼─────────┼─────────┤
|
||||||
│ 0 │ 'duplicate' │ 'en' │ 'Bravo.us@East' │ '140' │ 'Bravo' │
|
│ 0 │ 'duplicate' │ 'en' │ 'Bravo.us@East' │ '140' │ 'Bravo' │
|
||||||
└─────────┴─────────────┴──────┴─────────────────┴─────────┴─────────┘
|
└─────────┴─────────────┴──────┴─────────────────┴─────────┴─────────┘
|
||||||
|
|
||||||
1 problems (1 errors, 0 warnings) in 1 file(s)
|
1 problems (1 errors, 0 warnings) in 1 file(s)
|
||||||
`)
|
`)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('will show a message if the file contains a channel with wrong channel id', () => {
|
it('will show a message if the file contains a channel with wrong channel id', () => {
|
||||||
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/wrong_channel_id.channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/wrong_channel_id.channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
expect(stdout).toContain(`
|
expect(stdout).toContain(`
|
||||||
┌─────────┬────────────────────┬──────┬────────────────────┬─────────┬─────────────────────┐
|
┌─────────┬────────────────────┬──────┬────────────────────┬─────────┬─────────────────────┐
|
||||||
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
||||||
├─────────┼────────────────────┼──────┼────────────────────┼─────────┼─────────────────────┤
|
├─────────┼────────────────────┼──────┼────────────────────┼─────────┼─────────────────────┤
|
||||||
│ 0 │ 'wrong_channel_id' │ 'en' │ 'CNNInternational' │ '140' │ 'CNN International' │
|
│ 0 │ 'wrong_channel_id' │ 'en' │ 'CNNInternational' │ '140' │ 'CNN International' │
|
||||||
└─────────┴────────────────────┴──────┴────────────────────┴─────────┴─────────────────────┘
|
└─────────┴────────────────────┴──────┴────────────────────┴─────────┴─────────────────────┘
|
||||||
|
|
||||||
1 problems (0 errors, 1 warnings) in 1 file(s)
|
1 problems (0 errors, 1 warnings) in 1 file(s)
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('will show a message if the file contains a channel with wrong feed id', () => {
|
it('will show a message if the file contains a channel with wrong feed id', () => {
|
||||||
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/wrong_feed_id.channels.xml`
|
const cmd = `${ENV_VAR} npm run channels:validate --- tests/__data__/input/channels_validate/wrong_feed_id.channels.xml`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
expect(stdout).toContain(`
|
expect(stdout).toContain(`
|
||||||
┌─────────┬─────────────────┬──────┬─────────────────┬─────────┬─────────┐
|
┌─────────┬─────────────────┬──────┬─────────────────┬─────────┬─────────┐
|
||||||
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
│ (index) │ type │ lang │ xmltv_id │ site_id │ name │
|
||||||
├─────────┼─────────────────┼──────┼─────────────────┼─────────┼─────────┤
|
├─────────┼─────────────────┼──────┼─────────────────┼─────────┼─────────┤
|
||||||
│ 0 │ 'wrong_feed_id' │ 'en' │ 'Bravo.us@West' │ '150' │ 'Bravo' │
|
│ 0 │ 'wrong_feed_id' │ 'en' │ 'Bravo.us@West' │ '150' │ 'Bravo' │
|
||||||
└─────────┴─────────────────┴──────┴─────────────────┴─────────┴─────────┘
|
└─────────┴─────────────────┴──────┴─────────────────┴─────────┴─────────┘
|
||||||
|
|
||||||
1 problems (0 errors, 1 warnings) in 1 file(s)
|
1 problems (0 errors, 1 warnings) in 1 file(s)
|
||||||
`)
|
`)
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -1,162 +1,114 @@
|
|||||||
import { pathToFileURL } from 'node:url'
|
import { pathToFileURL } from 'node:url'
|
||||||
import { execSync } from 'child_process'
|
import { execSync } from 'child_process'
|
||||||
import { Zip } from '@freearhey/core'
|
import fs from 'fs-extra'
|
||||||
import fs from 'fs-extra'
|
import path from 'path'
|
||||||
import path from 'path'
|
import pako from 'pako'
|
||||||
|
|
||||||
const ENV_VAR =
|
const ENV_VAR =
|
||||||
'cross-env SITES_DIR=tests/__data__/input/epg_grab/sites CURR_DATE=2022-10-20 DATA_DIR=tests/__data__/input/__data__'
|
'cross-env SITES_DIR=tests/__data__/input/epg_grab/sites CURR_DATE=2022-10-20 DATA_DIR=tests/__data__/input/data'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
})
|
})
|
||||||
|
|
||||||
describe('epg:grab', () => {
|
describe('epg:grab', () => {
|
||||||
it('can grab epg by site name', () => {
|
it('can grab epg by site name', () => {
|
||||||
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --output="${path.resolve(
|
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --output="${path.resolve(
|
||||||
'tests/__data__/output/guide.xml'
|
'tests/__data__/output/guides/base.guide.xml'
|
||||||
)}" --timeout=100`
|
)}"`
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
expect(content('tests/__data__/output/guides/base.guide.xml')).toEqual(
|
||||||
content('tests/__data__/expected/epg_grab/base.guide.xml')
|
content('tests/__data__/expected/epg_grab/base.guide.xml')
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('it will raise an error if the timeout is exceeded', () => {
|
it('can grab epg with curl option', () => {
|
||||||
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 cmd = `${ENV_VAR} npm run grab --- --site=example.com --curl --output="${path.resolve(
|
||||||
let errorThrown = false
|
'tests/__data__/output/guides/curl.guide.xml'
|
||||||
try {
|
)}"`
|
||||||
execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
// If no error is thrown, explicitly fail the test
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
fail('Expected command to throw an error due to timeout, but it did not.')
|
|
||||||
} catch (error) {
|
expect(stdout).toContain('curl https://example.com')
|
||||||
errorThrown = true
|
})
|
||||||
if (process.env.DEBUG === 'true') {
|
|
||||||
const stderr = error.stderr?.toString() || ''
|
it('can grab epg with wildcard as output', () => {
|
||||||
const stdout = error.stdout?.toString() || ''
|
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/wildcard/{site}/{lang}/guide.xml"`
|
||||||
const combined = stderr + stdout
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
console.log('stdout:', stdout)
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
console.log('stderr:', stderr)
|
|
||||||
console.log('combined:', combined)
|
expect(content('tests/__data__/output/guides/wildcard/example.com/en/guide.xml')).toEqual(
|
||||||
console.log('exit code:', error.exitCode)
|
content('tests/__data__/expected/epg_grab/wildcard/example.com/en/guide.xml')
|
||||||
console.log('Error output:', combined)
|
)
|
||||||
}
|
|
||||||
}
|
expect(content('tests/__data__/output/guides/wildcard/example.com/fr/guide.xml')).toEqual(
|
||||||
expect(errorThrown).toBe(true)
|
content('tests/__data__/expected/epg_grab/wildcard/example.com/fr/guide.xml')
|
||||||
})
|
)
|
||||||
|
})
|
||||||
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" --timeout=100`
|
it('can grab epg then language filter enabled', () => {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
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/{lang}/guide.xml --lang=fr`
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
expect(content('tests/__data__/output/guides/en/example.com.xml')).toEqual(
|
|
||||||
content('tests/__data__/expected/epg_grab/guides/en/example.com.xml')
|
expect(content('tests/__data__/output/guides/lang/fr/guide.xml')).toEqual(
|
||||||
)
|
content('tests/__data__/expected/epg_grab/lang/fr/guide.xml')
|
||||||
|
)
|
||||||
expect(content('tests/__data__/output/guides/fr/example.com.xml')).toEqual(
|
})
|
||||||
content('tests/__data__/expected/epg_grab/guides/fr/example.com.xml')
|
|
||||||
)
|
it('can grab epg then using a multi-language filter', () => {
|
||||||
})
|
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/multilang.guide.xml --lang=fr,it`
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
it('can grab epg then language filter enabled', () => {
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
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 --timeout=100`
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
expect(content('tests/__data__/output/guides/multilang.guide.xml')).toEqual(
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
content('tests/__data__/expected/epg_grab/multilang.guide.xml')
|
||||||
|
)
|
||||||
expect(content('tests/__data__/output/guides/fr/example.com.xml')).toEqual(
|
})
|
||||||
content('tests/__data__/expected/epg_grab/guides/fr/example.com.xml')
|
|
||||||
)
|
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/guides/custom_channels.guide.xml `
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
it('can grab epg then using a multi-language filter', () => {
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/example.com/example.com.channels.xml --output=tests/__data__/output/guides/{site}.xml --lang=fr,it --timeout=100`
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
expect(content('tests/__data__/output/guides/custom_channels.guide.xml')).toEqual(
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
content('tests/__data__/expected/epg_grab/custom_channels.guide.xml')
|
||||||
|
)
|
||||||
expect(content('tests/__data__/output/guides/example.com.xml')).toEqual(
|
})
|
||||||
content('tests/__data__/expected/epg_grab/lang.guide.xml')
|
|
||||||
)
|
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/guides/multiple_channels.guide.xml`
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
it('can grab epg via https proxy', () => {
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --proxy=https://bob:123456@proxy.com:1234 --output="${path.resolve(
|
|
||||||
'tests/__data__/output/guide.xml'
|
expect(content('tests/__data__/output/guides/multiple_channels.guide.xml')).toEqual(
|
||||||
)}" --timeout=100`
|
content('tests/__data__/expected/epg_grab/multiple_channels.guide.xml')
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
)
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
})
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
it('can grab epg with gzip option enabled', () => {
|
||||||
content('tests/__data__/expected/epg_grab/proxy.guide.xml')
|
const cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/sites/example2.com/example2.com.channels.xml --output="${path.resolve(
|
||||||
)
|
'tests/__data__/output/guides/gzip.guide.xml'
|
||||||
})
|
)}" --gzip `
|
||||||
|
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||||
it('can grab epg via socks5 proxy', () => {
|
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||||
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --proxy=socks5://bob:123456@proxy.com:1234 --output="${path.resolve(
|
|
||||||
'tests/__data__/output/guide.xml'
|
expect(content('tests/__data__/output/guides/gzip.guide.xml')).toEqual(
|
||||||
)}" --timeout=100`
|
content('tests/__data__/expected/epg_grab/gzip.guide.xml')
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
)
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
|
const expected = pako.ungzip(fs.readFileSync('tests/__data__/output/guides/gzip.guide.xml.gz'))
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
const result = pako.ungzip(
|
||||||
content('tests/__data__/expected/epg_grab/proxy.guide.xml')
|
fs.readFileSync('tests/__data__/expected/epg_grab/gzip.guide.xml.gz')
|
||||||
)
|
)
|
||||||
})
|
expect(expected).toEqual(result)
|
||||||
|
})
|
||||||
it('can grab epg with curl option', () => {
|
})
|
||||||
const cmd = `${ENV_VAR} npm run grab --- --site=example.com --curl --output="${path.resolve(
|
|
||||||
'tests/__data__/output/guide.xml'
|
function content(filepath: string) {
|
||||||
)}" --timeout=100`
|
return fs.readFileSync(pathToFileURL(filepath), {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
encoding: 'utf8'
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
})
|
||||||
|
}
|
||||||
expect(stdout).toContain('curl https://example.com')
|
|
||||||
})
|
|
||||||
|
|
||||||
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 --timeout=100`
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
|
||||||
content('tests/__data__/expected/epg_grab/template.guide.xml')
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
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 --timeout=100`
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
|
||||||
content('tests/__data__/expected/epg_grab/custom_channels.guide.xml')
|
|
||||||
)
|
|
||||||
})
|
|
||||||
|
|
||||||
it('can grab epg with gzip option enabled', () => {
|
|
||||||
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 --timeout=100`
|
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
|
||||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
|
||||||
|
|
||||||
expect(content('tests/__data__/output/guide.xml')).toEqual(
|
|
||||||
content('tests/__data__/expected/epg_grab/template.guide.xml')
|
|
||||||
)
|
|
||||||
|
|
||||||
const zip = new Zip()
|
|
||||||
const expected = zip.decompress(fs.readFileSync('tests/__data__/output/guide.xml.gz'))
|
|
||||||
const result = zip.decompress(
|
|
||||||
fs.readFileSync('tests/__data__/expected/epg_grab/template.guide.xml.gz')
|
|
||||||
)
|
|
||||||
expect(expected).toEqual(result)
|
|
||||||
})
|
|
||||||
})
|
|
||||||
|
|
||||||
function content(filepath: string) {
|
|
||||||
return fs.readFileSync(pathToFileURL(filepath), {
|
|
||||||
encoding: 'utf8'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
|
|||||||
Reference in New Issue
Block a user