mirror of
https://github.com/iptv-org/database.git
synced 2024-11-26 12:31:27 -05:00
Merge branch 'master' of https://github.com/AntiPontifex/database
This commit is contained in:
commit
7aa78e976b
4 changed files with 180 additions and 163 deletions
File diff suppressed because it is too large
Load diff
|
@ -23,12 +23,11 @@ async function main() {
|
||||||
if (file.extension() !== 'csv') continue
|
if (file.extension() !== 'csv') continue
|
||||||
|
|
||||||
const csv = await dataStorage.load(file.basename())
|
const csv = await dataStorage.load(file.basename())
|
||||||
if (/\s+$/.test(csv))
|
|
||||||
return handleError(`Error: empty lines at the end of file not allowed (${filepath})`)
|
|
||||||
|
|
||||||
const rows = csv.split(/\r\n/)
|
const rows = csv.split(/\r\n/)
|
||||||
const headers = rows[0].split(',')
|
const headers = rows[0].split(',')
|
||||||
for (const [i, line] of rows.entries()) {
|
for (const [i, line] of rows.entries()) {
|
||||||
|
if (!line.trim()) continue
|
||||||
if (line.indexOf('\n') > -1)
|
if (line.indexOf('\n') > -1)
|
||||||
return handleError(
|
return handleError(
|
||||||
`Error: row ${i + 1} has the wrong line ending character, should be CRLF (${filepath})`
|
`Error: row ${i + 1} has the wrong line ending character, should be CRLF (${filepath})`
|
||||||
|
|
|
@ -6,20 +6,6 @@ type ExecError = {
|
||||||
}
|
}
|
||||||
|
|
||||||
describe('db:validate', () => {
|
describe('db:validate', () => {
|
||||||
it('shows an error if there is an empty line at the end of the file', () => {
|
|
||||||
try {
|
|
||||||
execSync('DATA_DIR=tests/__data__/input/validate/empty_line npm run db:validate', {
|
|
||||||
encoding: 'utf8'
|
|
||||||
})
|
|
||||||
process.exit(1)
|
|
||||||
} catch (error) {
|
|
||||||
expect((error as ExecError).status).toBe(1)
|
|
||||||
expect((error as ExecError).stdout).toContain(
|
|
||||||
'Error: empty lines at the end of file not allowed (channels.csv)'
|
|
||||||
)
|
|
||||||
}
|
|
||||||
})
|
|
||||||
|
|
||||||
it('shows an error if the number of columns in a row is incorrect', () => {
|
it('shows an error if the number of columns in a row is incorrect', () => {
|
||||||
try {
|
try {
|
||||||
execSync('DATA_DIR=tests/__data__/input/validate/wrong_num_cols npm run db:validate', {
|
execSync('DATA_DIR=tests/__data__/input/validate/wrong_num_cols npm run db:validate', {
|
||||||
|
|
Loading…
Reference in a new issue