Skip to content

Commit

Permalink
feature: added e2e tests for latitude run
Browse files Browse the repository at this point in the history
E2E test to ensure the query running actually works.
  • Loading branch information
geclos committed Apr 29, 2024
1 parent fb5771b commit 4e8461b
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 6 deletions.
4 changes: 3 additions & 1 deletion packages/cli/tests/e2e/dev.cjs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ const { spawn } = require('child_process')
const path = require('path')

function dev () {
return new Promise((resolve) => {
const spawned = spawn('node', [
path.join(__dirname, '../../dist/cli.js'),
'dev',
Expand All @@ -24,7 +25,7 @@ function dev () {
console.log('Server started successfully!')

spawned.kill()
process.exit()
resolve()
}
})

Expand All @@ -45,6 +46,7 @@ function dev () {

process.exit(1)
}, 30000)
})
}

module.exports = dev
11 changes: 11 additions & 0 deletions packages/cli/tests/e2e/run.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
const { spawnSync } = require('child_process')
const { writeFileSync } = require('fs')

export default function run () {
writeFileSync('queries/nested/source.yml', 'type: duckdb')
writeFileSync('queries/nested/titles.csv', 'title\nHello, World!')
writeFileSync('queries/nested/sql/test.sql', "SELECT * FROM read_csv_auto('queries/nested/titles.csv') LIMIT 1")

spawnSync('npm', ['install', '--save', '@latitude-data/duckdb-connector'])
spawnSync('latitude', ['run', 'queries/nested/sql/test.sql'])
}
12 changes: 7 additions & 5 deletions packages/cli/tests/e2e/start.cjs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
const run = require('./run.cjs')
const dev = require('./dev.cjs')
const path = require('path')
const { spawn, spawnSync } = require('child_process')
Expand All @@ -22,16 +23,17 @@ const spawned = spawn('node', [
'--template',
'default',
'--verbose'
])
], { stdio: 'inherit' })

spawned.stdout.pipe(process.stdout)
spawned.stderr.pipe(process.stderr)
spawned.on('close', function (code) {
spawned.on('close', async (code) => {
if (code !== 0) process.exit(code)

ok = true

dev()
await dev()
run()

process.exit()
})

spawned.on('error', function (error) {
Expand Down

0 comments on commit 4e8461b

Please sign in to comment.