Update tests

pull/20957/head
freearhey 4 weeks ago
parent 32e38bda52
commit 74b3cff1d2

@ -3,15 +3,17 @@ import fs from 'fs-extra'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
})
it('can create streams.json', () => {
execSync(
'STREAMS_DIR=tests/__data__/input/streams_generate API_DIR=tests/__data__/output/.api npm run api:generate',
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/api_generate API_DIR=tests/__data__/output/.api npm run api:generate',
{ encoding: 'utf8' }
)
})
it('can create streams.json', () => {
expect(content('output/.api/streams.json')).toMatchObject(content('expected/.api/streams.json'))
expect(content('output/.api/streams.json')).toMatchObject(
content('expected/api_generate/.api/streams.json')
)
})
function content(filepath: string) {

@ -4,7 +4,7 @@ import { glob } from 'glob'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync('tests/__data__/input/streams_format', 'tests/__data__/output/streams')
fs.copySync('tests/__data__/input/playlist_format', 'tests/__data__/output/streams')
})
it('can format playlists', () => {
@ -13,12 +13,12 @@ it('can format playlists', () => {
})
const files = glob
.sync('tests/__data__/expected/streams_format/*.m3u')
.map(f => f.replace('tests/__data__/expected/streams_format/', ''))
.sync('tests/__data__/expected/playlist_format/*.m3u')
.map(f => f.replace('tests/__data__/expected/playlist_format/', ''))
files.forEach(filepath => {
expect(content(`output/streams/${filepath}`), filepath).toBe(
content(`expected/streams_format/${filepath}`)
content(`expected/playlist_format/${filepath}`)
)
})
})

@ -4,24 +4,26 @@ import * as glob from 'glob'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
})
it('can generate playlists and logs', () => {
execSync(
'STREAMS_DIR=tests/__data__/input/streams_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate',
'STREAMS_DIR=tests/__data__/input/playlist_generate DATA_DIR=tests/__data__/input/data PUBLIC_DIR=tests/__data__/output/.gh-pages LOGS_DIR=tests/__data__/output/logs npm run playlist:generate',
{ encoding: 'utf8' }
)
})
it('can generate playlists and logs', () => {
const playlists = glob
.sync('tests/__data__/expected/.gh-pages/**/*.m3u')
.map((file: string) => file.replace('tests/__data__/expected/', ''))
.sync('tests/__data__/expected/playlist_generate/.gh-pages/**/*.m3u')
.map((file: string) => file.replace('tests/__data__/expected/playlist_generate/', ''))
playlists.forEach((filepath: string) => {
expect(content(`output/${filepath}`), filepath).toBe(content(`expected/${filepath}`))
expect(content(`output/${filepath}`), filepath).toBe(
content(`expected/playlist_generate/${filepath}`)
)
})
expect(content('output/logs/generators.log').split('\n').sort()).toStrictEqual(
content('expected/logs/generators.log').split('\n').sort()
content('expected/playlist_generate/logs/generators.log').split('\n').sort()
)
})

@ -7,13 +7,13 @@ type ExecError = {
it('shows an error if the playlist contains a broken link', () => {
try {
execSync('ROOT_DIR=tests/__data__/input npm run playlist:test streams_test/ag.m3u', {
execSync('ROOT_DIR=tests/__data__/input npm run playlist:test playlist_test/ag.m3u', {
encoding: 'utf8'
})
process.exit(1)
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain('streams_test/ag.m3u')
expect((error as ExecError).stdout).toContain('playlist_test/ag.m3u')
expect((error as ExecError).stdout).toContain('2 problems (1 errors, 1 warnings)')
}
})

@ -4,10 +4,10 @@ import { glob } from 'glob'
beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.copySync('tests/__data__/input/streams_update', 'tests/__data__/output/streams')
fs.copySync('tests/__data__/input/playlist_update', 'tests/__data__/output/streams')
})
it('can format playlists', () => {
it('can update playlists', () => {
const stdout = execSync(
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/output/streams npm run playlist:update --silent',
{
@ -16,17 +16,17 @@ it('can format playlists', () => {
)
const files = glob
.sync('tests/__data__/expected/streams_update/*.m3u')
.map(f => f.replace('tests/__data__/expected/streams_update/', ''))
.sync('tests/__data__/expected/playlist_update/*.m3u')
.map(f => f.replace('tests/__data__/expected/playlist_update/', ''))
files.forEach(filepath => {
expect(content(`output/streams/${filepath}`), filepath).toBe(
content(`expected/streams_update/${filepath}`)
content(`expected/playlist_update/${filepath}`)
)
})
expect(stdout).toBe(
'OUTPUT=closes #14151, closes #14140, closes #14110, closes #14120, closes #14175, closes #14105, closes #14104, closes #14057, closes #14034, closes #13964, closes #13893, closes #13881, closes #13793, closes #13751, closes #13715\n'
'OUTPUT=closes #14151, closes #14150, closes #14110, closes #14120, closes #14175, closes #14105, closes #14104, closes #14057, closes #14034, closes #13964, closes #13893, closes #13881, closes #13793, closes #13751, closes #13715\n'
)
})

@ -8,7 +8,7 @@ type ExecError = {
it('show an error if channel id in the blocklist', () => {
try {
execSync(
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_validate npm run playlist:validate -- us_blocked.m3u',
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/playlist_validate npm run playlist:validate -- us_blocked.m3u',
{
encoding: 'utf8'
}
@ -17,7 +17,7 @@ it('show an error if channel id in the blocklist', () => {
} catch (error) {
expect((error as ExecError).status).toBe(1)
expect((error as ExecError).stdout).toContain(`us_blocked.m3u
2 error "FoxSports2Asia.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002)
2 error "FoxSports2.us" is on the blocklist due to claims of copyright holders (https://github.com/iptv-org/iptv/issues/0002)
4 error "TVN.pl" is on the blocklist due to NSFW content (https://github.com/iptv-org/iptv/issues/0003)
2 problems (2 errors, 0 warnings)`)
@ -26,7 +26,7 @@ it('show an error if channel id in the blocklist', () => {
it('show a warning if channel has wrong id', () => {
const stdout = execSync(
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_validate npm run playlist:validate -- wrong_id.m3u',
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/playlist_validate npm run playlist:validate -- wrong_id.m3u',
{
encoding: 'utf8'
}

@ -6,23 +6,23 @@ beforeEach(() => {
fs.emptyDirSync('tests/__data__/output')
fs.mkdirSync('tests/__data__/output/.readme')
fs.copyFileSync(
'tests/__data__/input/.readme/config.json',
'tests/__data__/input/readme_update/.readme/config.json',
'tests/__data__/output/.readme/config.json'
)
fs.copyFileSync(
'tests/__data__/input/.readme/template.md',
'tests/__data__/input/readme_update/.readme/template.md',
'tests/__data__/output/.readme/template.md'
)
execSync(
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/logs README_DIR=tests/__data__/output/.readme npm run readme:update',
'DATA_DIR=tests/__data__/input/data LOGS_DIR=tests/__data__/input/readme_update README_DIR=tests/__data__/output/.readme npm run readme:update',
{ encoding: 'utf8' }
)
})
it('can update readme.md', () => {
expect(content('tests/__data__/output/readme.md')).toEqual(
content('tests/__data__/expected/_readme.md')
content('tests/__data__/expected/readme_update/_readme.md')
)
})

@ -2,7 +2,7 @@ import { execSync } from 'child_process'
it('can create report', () => {
const stdout = execSync(
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/streams_report npm run report:create',
'DATA_DIR=tests/__data__/input/data STREAMS_DIR=tests/__data__/input/report_create npm run report:create',
{
encoding: 'utf8'
}
@ -10,18 +10,15 @@ it('can create report', () => {
expect(
stdout.includes(`
(index) issueNumber type channelId streamUrl status
0 14120 'streams:edit' 'boo.us' 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' 'invalid_id'
1 14135 'streams:add' 'BBCWorldNewsSouthAsia.uk' 'http://103.199.161.254/Content/bbcworld/Live/Channel%28BBCworld%29/Stream%2801%29/index.m3u8' 'wrong_id'
2 14140 'streams:add' undefined undefined 'missing_id'
3 14175 'streams:add' 'TFX.fr' 'http://livetv.ktv.zone/13/play.m3u8' 'duplicate'
4 14177 'streams:add' 'TUTV.us' 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' 'on_playlist'
5 14178 'streams:add' 'TV3.my' 'https://live-streams-ssai-01.tonton.com.my/live/2dd2b7cd-1b34-4871-b669-57b5c9beca23/live.isml/.m3u8' 'blocked'
6 16120 'broken stream' undefined 'http://190.61.102.67:2000/play/a038/index.m3u8' 'wrong_link'
7 19956 'channel search' 'CNBCe.tr' undefined 'invalid_id'
8 19957 'channel search' '13thStreet.au' undefined 'closed'
`)
(index) issueNumber type streamId streamUrl status
0 14120 'streams:edit' 'boo.us' 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' 'invalid_id'
1 14135 'streams:add' 'BBCWorldNews.uk@SouthAsia' 'http://103.199.161.254/Content/bbcworld/Live/Channel%28BBCworld%29/Stream%2801%29/index.m3u8' 'wrong_id'
2 14177 'streams:add' 'TUTV.us' 'https://livestream.telvue.com/templeuni1/f7b44cfafd5c52223d5498196c8a2e7b.sdp/playlist.m3u8' 'on_playlist'
3 14178 'streams:add' 'TV3.my' 'https://live-streams-ssai-01.tonton.com.my/live/2dd2b7cd-1b34-4871-b669-57b5c9beca23/live.isml/.m3u8...' 'blocked'
4 16120 'broken stream' undefined 'http://190.61.102.67:2000/play/a038/index.m3u8' 'wrong_link'
5 19956 'channel search' 'CNBCe.tr' undefined 'invalid_id'
`)
).toBe(true)
})

Loading…
Cancel
Save