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
67387a0a29
commit
37b4197fb2
6 changed files with 198 additions and 150 deletions
38
tests/commands/db/export.test.ts
Normal file
38
tests/commands/db/export.test.ts
Normal file
|
@ -0,0 +1,38 @@
|
|||
import { execSync } from 'child_process'
|
||||
import * as fs from 'fs-extra'
|
||||
import os from 'os'
|
||||
|
||||
beforeEach(() => {
|
||||
fs.emptyDirSync('tests/__data__/output')
|
||||
})
|
||||
|
||||
describe('db:export', () => {
|
||||
let ENV_VAR = 'DATA_DIR=tests/__data__/input/db/export/data API_DIR=tests/__data__/output/api'
|
||||
if (os.platform() === 'win32') {
|
||||
ENV_VAR =
|
||||
'SET "DATA_DIR=tests/__data__/input/db/export/data" && SET "API_DIR=tests/__data__/output/api" &&'
|
||||
}
|
||||
|
||||
it('can export data as json', () => {
|
||||
const cmd = `${ENV_VAR} npm run db:export`
|
||||
const stdout = execSync(cmd, { encoding: 'utf8' })
|
||||
if (process.env.DEBUG === 'true') console.log(cmd, stdout)
|
||||
|
||||
expect(content('output/api/blocklist.json')).toEqual(
|
||||
content('expected/db/export/api/blocklist.json')
|
||||
)
|
||||
expect(content('output/api/channels.json')).toEqual(
|
||||
content('expected/db/export/api/channels.json')
|
||||
)
|
||||
expect(content('output/api/timezones.json')).toEqual(
|
||||
content('expected/db/export/api/timezones.json')
|
||||
)
|
||||
expect(content('output/api/feeds.json')).toEqual(content('expected/db/export/api/feeds.json'))
|
||||
})
|
||||
})
|
||||
|
||||
function content(filepath: string) {
|
||||
return fs.readFileSync(`tests/__data__/${filepath}`, {
|
||||
encoding: 'utf8'
|
||||
})
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue