From 2e560f137ee1ac955972ed8539359c96334f6816 Mon Sep 17 00:00:00 2001 From: Stepan Kuzmin Date: Thu, 2 Jul 2020 11:25:56 +0300 Subject: [PATCH] fix: fix cli ssl option parsing (#158) re #157 --- .github/workflows/ci.yml | 1 - index.js | 7 +++++-- test/index.js | 44 +++++++++++++++++++++++++++++++++++----- 3 files changed, 44 insertions(+), 8 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index 4263f12..a924ad2 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -11,7 +11,6 @@ on: jobs: tests: runs-on: ubuntu-latest - container: node:10.18-jessie services: postgres: diff --git a/index.js b/index.js index 93b5f15..87f71cb 100755 --- a/index.js +++ b/index.js @@ -54,8 +54,11 @@ const connection = (connectionString && parse(connectionString)) || { port: opt['--port'] || process.env.PGPORT || process.env.POSTGRES_PORT, user: opt['--user'] || process.env.PGUSER || process.env.POSTGRES_USER, password: - opt['--password'] || process.env.PGPASSWORD || process.env.POSTGRES_PASSWORD, - ssl: opt['--ssl'] || process.env.PGSSL || process.env.POSTGRES_SSL + opt['--password'] || + process.env.PGPASSWORD || + process.env.POSTGRES_PASSWORD, + ssl: + (opt['--ssl'] || process.env.PGSSL || process.env.POSTGRES_SSL) === 'true' }; const options = { diff --git a/test/index.js b/test/index.js index 089868a..2d988b8 100644 --- a/test/index.js +++ b/test/index.js @@ -37,7 +37,13 @@ test('migrate', async t => { await pgMigrate.migrate(); await pgMigrate.end(); - const db = pgp({ database, user }); + const db = pgp({ + host, + port, + database, + user, + password + }); await db .oneOrNone(tableExistsQuery, { schemaName, tableName }) @@ -57,12 +63,26 @@ test('migrate', async t => { test('rollback', async t => { t.plan(3); - const pgMigrate = new PgMigrate({ database, user, migrationsDir }); + const pgMigrate = new PgMigrate({ + host, + port, + database, + user, + password, + migrationsDir + }); + await pgMigrate.connect(); await pgMigrate.rollback(); await pgMigrate.end(); - const db = pgp({ database, user }); + const db = pgp({ + host, + port, + database, + user, + password + }); await db .oneOrNone(tableExistsQuery, { schemaName, tableName }) @@ -82,12 +102,26 @@ test('rollback', async t => { test('reset', async t => { t.plan(3); - const pgMigrate = new PgMigrate({ database, user, migrationsDir }); + const pgMigrate = new PgMigrate({ + host, + port, + database, + user, + password, + migrationsDir + }); + await pgMigrate.connect(); await pgMigrate.reset(); await pgMigrate.end(); - const db = pgp({ database, user }); + const db = pgp({ + host, + port, + database, + user, + password + }); await db .oneOrNone(tableExistsQuery, { schemaName, tableName })