From 63ab90ee507b4606226ac9661d1a0461ac704b75 Mon Sep 17 00:00:00 2001 From: freearhey <7253922+freearhey@users.noreply.github.com> Date: Mon, 17 Aug 2026 01:00:01 +0300 Subject: [PATCH] Update validate.test.ts --- tests/commands/playlist/validate.test.ts | 61 ++++++++++++++++++++---- 1 file changed, 53 insertions(+), 8 deletions(-) diff --git a/tests/commands/playlist/validate.test.ts b/tests/commands/playlist/validate.test.ts index e87ce1843b..86692fba87 100644 --- a/tests/commands/playlist/validate.test.ts +++ b/tests/commands/playlist/validate.test.ts @@ -12,7 +12,9 @@ describe('playlist:validate', () => { it('show an error if channel id in the blocklist', () => { const cmd = `${ENV_VAR} npm run playlist:validate -- us_blocked.m3u` try { - execSync(cmd, { encoding: 'utf8' }) + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + process.exit(0) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) expect((error as ExecError).stdout).toContain('us_blocked.m3u') @@ -26,22 +28,64 @@ describe('playlist:validate', () => { } }) - it('show a warning if channel has wrong id', () => { - const cmd = `${ENV_VAR} npm run playlist:validate -- wrong_id.m3u` + it('show a warning if stream is missing a channel id', () => { + const cmd = `${ENV_VAR} npm run playlist:validate -- missing_channel_id.m3u` try { - execSync(cmd, { encoding: 'utf8' }) + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + expect(stdout).toContain( + 'missing_channel_id.m3u\n 2 warning "https://example.com/playlist2.m3u8" is missing a channel ID\n\n1 problems (0 errors, 1 warnings)\n' + ) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) - 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' + } + }) + + it('show a warning if stream has wrong channel id', () => { + const cmd = `${ENV_VAR} npm run playlist:validate -- wrong_channel_id.m3u` + try { + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + expect(stdout).toContain( + 'wrong_channel_id.m3u\n 2 warning "qib22lAq1L.us" is not in the database\n\n1 problems (0 errors, 1 warnings)\n' ) + } catch (error) { + if (process.env.DEBUG === 'true') console.log(cmd, error) + } + }) + + it('show a warning if stream is missing a feed id', () => { + const cmd = `${ENV_VAR} npm run playlist:validate -- missing_feed_id.m3u` + try { + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + expect(stdout).toContain( + 'missing_feed_id.m3u\n 2 warning "https://example.com/playlist2.m3u8" is missing a feed ID\n\n1 problems (0 errors, 1 warnings)\n' + ) + } catch (error) { + if (process.env.DEBUG === 'true') console.log(cmd, error) + } + }) + + it('show a warning if stream has a wrong feed id', () => { + const cmd = `${ENV_VAR} npm run playlist:validate -- wrong_feed_id.m3u` + try { + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + expect(stdout).toContain( + 'wrong_feed_id.m3u\n 2 warning There is no feed with the ID "HD" in the database for the "Channel7.bz" channel\n\n1 problems (0 errors, 1 warnings)\n' + ) + } catch (error) { + if (process.env.DEBUG === 'true') console.log(cmd, error) } }) it('show a error if stream has an invalid url', () => { const cmd = `${ENV_VAR} npm run playlist:validate -- invalid_url.m3u` try { - execSync(cmd, { encoding: 'utf8' }) + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) + process.exit(0) } catch (error) { if (process.env.DEBUG === 'true') console.log(cmd, error) expect((error as ExecError).stdout).toContain('invalid_url.m3u') @@ -54,6 +98,7 @@ describe('playlist:validate', () => { it('skip the file if it does not exist', () => { const cmd = `${ENV_VAR} npm run playlist:validate -- missing.m3u` - execSync(cmd, { encoding: 'utf8' }) + const stdout = execSync(cmd, { encoding: 'utf8' }) + if (process.env.DEBUG === 'true') console.log(cmd, stdout) }) })