mirror of
https://github.com/iptv-org/epg
synced 2025-12-16 10:26:41 -05:00
tries and retries
This commit is contained in:
@@ -102,10 +102,7 @@ async function main() {
|
|||||||
runJob({ logger, parsedChannels })
|
runJob({ logger, parsedChannels })
|
||||||
}
|
}
|
||||||
|
|
||||||
main().catch(error => {
|
main()
|
||||||
console.error('ERR:', error.message)
|
|
||||||
process.exit(1)
|
|
||||||
})
|
|
||||||
|
|
||||||
async function runJob({ logger, parsedChannels }: { logger: Logger; parsedChannels: Collection }) {
|
async function runJob({ logger, parsedChannels }: { logger: Logger; parsedChannels: Collection }) {
|
||||||
const timer = new Timer()
|
const timer = new Timer()
|
||||||
|
|||||||
@@ -98,18 +98,25 @@ describe('epg:grab', () => {
|
|||||||
|
|
||||||
it('it will raise an error if the timeout is exceeded', () => {
|
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 cmd = `${ENV_VAR} npm run grab --- --channels=tests/__data__/input/epg_grab/custom.channels.xml --output=tests/__data__/output/guide.xml --timeout=0`
|
||||||
|
let errorThrown = false
|
||||||
try {
|
try {
|
||||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
||||||
expect(stdout).toContain('ERR: Connection timeout')
|
// If no error is thrown, explicitly fail the test
|
||||||
|
fail('Expected command to throw an error due to timeout, but it did not.')
|
||||||
} catch (error) {
|
} catch (error) {
|
||||||
// in the eventuality of an error that doesn't pipe in properly, check stdout and stderr.
|
errorThrown = true
|
||||||
const stderr = error.stderr?.toString() || ''
|
if (process.env.DEBUG === 'true') {
|
||||||
const stdout = error.stdout?.toString() || ''
|
const stderr = error.stderr?.toString() || ''
|
||||||
const combined = stderr + stdout
|
const stdout = error.stdout?.toString() || ''
|
||||||
|
const combined = stderr + stdout
|
||||||
if (process.env.DEBUG === 'true') console.log('Error output:', combined)
|
console.log('stdout:', stdout)
|
||||||
expect(combined).toContain('ERR: Connection timeout')
|
console.log('stderr:', stderr)
|
||||||
|
console.log('combined:', combined)
|
||||||
|
console.log('exit code:', error.exitCode)
|
||||||
|
console.log('Error output:', combined)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
expect(errorThrown).toBe(true)
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can grab epg via https proxy', () => {
|
it('can grab epg via https proxy', () => {
|
||||||
|
|||||||
Reference in New Issue
Block a user