2024-02-14 05:11:34 +00:00
|
|
|
import fs from 'fs'
|
2024-01-15 19:08:48 +00:00
|
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
|
import { parquetRead } from '../src/hyparquet.js'
|
|
|
|
|
import { toJson } from '../src/toJson.js'
|
2024-02-14 05:11:34 +00:00
|
|
|
import { fileToAsyncBuffer, fileToJson } from './helpers.js'
|
2024-01-15 19:08:48 +00:00
|
|
|
|
|
|
|
|
describe('parquetMetadataAsync', () => {
|
2024-02-14 05:11:34 +00:00
|
|
|
it('should parse metadata from all test files', async () => {
|
|
|
|
|
const files = fs.readdirSync('test/files')
|
|
|
|
|
for (const file of files) {
|
|
|
|
|
if (!file.endsWith('.parquet')) continue
|
|
|
|
|
const asyncBuffer = fileToAsyncBuffer(`test/files/${file}`)
|
|
|
|
|
await parquetRead({
|
|
|
|
|
file: asyncBuffer,
|
|
|
|
|
onComplete: (rows) => {
|
|
|
|
|
const base = file.replace('.parquet', '')
|
|
|
|
|
const expected = fileToJson(`test/files/${base}.json`)
|
|
|
|
|
expect(toJson(rows)).toEqual(expected)
|
|
|
|
|
},
|
|
|
|
|
})
|
|
|
|
|
}
|
2024-01-15 19:08:48 +00:00
|
|
|
})
|
|
|
|
|
})
|