mirror of
https://github.com/iptv-org/database.git
synced 2025-05-10 03:30:01 -04:00
Update tests
This commit is contained in:
parent
b0c8d58c70
commit
77680e2dc9
3 changed files with 22 additions and 7 deletions
|
@ -7,7 +7,7 @@ beforeEach(() => {
|
||||||
|
|
||||||
it('can export data as json', () => {
|
it('can export data as json', () => {
|
||||||
execSync(
|
execSync(
|
||||||
'DATA_DIR=tests/__data__/input/data API_DIR=tests/__data__/output/api npm run db:export',
|
'DATA_DIR=tests/__data__/input/export/data API_DIR=tests/__data__/output/api npm run db:export',
|
||||||
{
|
{
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
}
|
}
|
||||||
|
@ -15,6 +15,8 @@ it('can export data as json', () => {
|
||||||
|
|
||||||
expect(content('output/api/blocklist.json')).toEqual(content('expected/api/blocklist.json'))
|
expect(content('output/api/blocklist.json')).toEqual(content('expected/api/blocklist.json'))
|
||||||
expect(content('output/api/channels.json')).toEqual(content('expected/api/channels.json'))
|
expect(content('output/api/channels.json')).toEqual(content('expected/api/channels.json'))
|
||||||
|
expect(content('output/api/timezones.json')).toEqual(content('expected/api/timezones.json'))
|
||||||
|
expect(content('output/api/feeds.json')).toEqual(content('expected/api/feeds.json'))
|
||||||
})
|
})
|
||||||
|
|
||||||
function content(filepath: string) {
|
function content(filepath: string) {
|
||||||
|
|
|
@ -3,7 +3,7 @@ import * as fs from 'fs-extra'
|
||||||
|
|
||||||
beforeEach(() => {
|
beforeEach(() => {
|
||||||
fs.emptyDirSync('tests/__data__/output')
|
fs.emptyDirSync('tests/__data__/output')
|
||||||
fs.copySync('tests/__data__/input/data', 'tests/__data__/output/data')
|
fs.copySync('tests/__data__/input/update/data', 'tests/__data__/output/data')
|
||||||
})
|
})
|
||||||
|
|
||||||
it('can update db with data from issues', () => {
|
it('can update db with data from issues', () => {
|
||||||
|
@ -13,8 +13,9 @@ it('can update db with data from issues', () => {
|
||||||
|
|
||||||
expect(content('output/data/blocklist.csv')).toEqual(content('expected/data/blocklist.csv'))
|
expect(content('output/data/blocklist.csv')).toEqual(content('expected/data/blocklist.csv'))
|
||||||
expect(content('output/data/channels.csv')).toEqual(content('expected/data/channels.csv'))
|
expect(content('output/data/channels.csv')).toEqual(content('expected/data/channels.csv'))
|
||||||
|
expect(content('output/data/feeds.csv')).toEqual(content('expected/data/feeds.csv'))
|
||||||
expect(stdout).toEqual(
|
expect(stdout).toEqual(
|
||||||
'OUTPUT=closes #5871, closes #5901, closes #5701, closes #5900, closes #5899, closes #5898, closes #5897, closes #5891'
|
'OUTPUT=closes #6871, closes #5871, closes #7901, closes #5901, closes #5701, closes #8900, closes #5900, closes #5899, closes #5898, closes #5897, closes #5891'
|
||||||
)
|
)
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
|
@ -46,10 +46,13 @@ describe('db:validate', () => {
|
||||||
expect((error as ExecError).stdout).toContain(
|
expect((error as ExecError).stdout).toContain(
|
||||||
'entry with the channel "002RadioTV.do" and ref "eee" already exists'
|
'entry with the channel "002RadioTV.do" and ref "eee" already exists'
|
||||||
)
|
)
|
||||||
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
'entry with the channel "002RadioTV.do" and id "SD" already exists'
|
||||||
|
)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
it('shows an error if an invalid value is specified', () => {
|
it('shows an error if the data contains an error', () => {
|
||||||
try {
|
try {
|
||||||
execSync('DATA_DIR=tests/__data__/input/validate/invalid_value npm run db:validate', {
|
execSync('DATA_DIR=tests/__data__/input/validate/invalid_value npm run db:validate', {
|
||||||
encoding: 'utf8'
|
encoding: 'utf8'
|
||||||
|
@ -57,13 +60,22 @@ describe('db:validate', () => {
|
||||||
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('"aaa.us" is missing in the channels.csv')
|
||||||
expect((error as ExecError).stdout).toContain(
|
expect((error as ExecError).stdout).toContain(
|
||||||
'2 "aaa.us" is missing in the channels.csv'
|
'002RadioTV.do: "website" must be a valid uri with a scheme matching the http|https pattern'
|
||||||
)
|
)
|
||||||
expect((error as ExecError).stdout).toContain(
|
expect((error as ExecError).stdout).toContain(
|
||||||
'2 002RadioTV.do: "website" must be a valid uri with a scheme matching the http|https pattern'
|
'entry with the channel "002RadioTV.do" and is_main "true" already exists'
|
||||||
)
|
)
|
||||||
expect((error as ExecError).stdout).toContain('2 error(s)')
|
expect((error as ExecError).stdout).toContain('"0TV.dk" is missing in the channels.csv')
|
||||||
|
expect((error as ExecError).stdout).toContain('"SD" has an invalid replaced_by "M5.hu@HD"')
|
||||||
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
'"0TV.dk@SD" has the wrong timezone "Europe/Copenhagen"'
|
||||||
|
)
|
||||||
|
expect((error as ExecError).stdout).toContain(
|
||||||
|
'SD: "video_format" with value "576I" fails to match the required pattern'
|
||||||
|
)
|
||||||
|
expect((error as ExecError).stdout).toContain('7 error(s)')
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue