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 })
|
||||
}
|
||||
|
||||
main().catch(error => {
|
||||
console.error('ERR:', error.message)
|
||||
process.exit(1)
|
||||
})
|
||||
main()
|
||||
|
||||
async function runJob({ logger, parsedChannels }: { logger: Logger; parsedChannels: Collection }) {
|
||||
const timer = new Timer()
|
||||
|
||||
@@ -98,18 +98,25 @@ 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`
|
||||
let errorThrown = false
|
||||
try {
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
expect(stdout).toContain('ERR: Connection timeout')
|
||||
execSync(cmd, { encoding: 'utf8', stdio: ['pipe', 'pipe', 'pipe'] })
|
||||
// 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) {
|
||||
// in the eventuality of an error that doesn't pipe in properly, check stdout and stderr.
|
||||
errorThrown = true
|
||||
if (process.env.DEBUG === 'true') {
|
||||
const stderr = error.stderr?.toString() || ''
|
||||
const stdout = error.stdout?.toString() || ''
|
||||
const combined = stderr + stdout
|
||||
|
||||
if (process.env.DEBUG === 'true') console.log('Error output:', combined)
|
||||
expect(combined).toContain('ERR: Connection timeout')
|
||||
console.log('stdout:', stdout)
|
||||
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', () => {
|
||||
|
||||
Reference in New Issue
Block a user