Skip to content

Commit

Permalink
fix: fix cli ssl option parsing (#158)
Browse files Browse the repository at this point in the history
re #157
  • Loading branch information
stepankuzmin authored Jul 2, 2020
1 parent c11da3d commit 2e560f1
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 8 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,6 @@ on:
jobs:
tests:
runs-on: ubuntu-latest
container: node:10.18-jessie

services:
postgres:
Expand Down
7 changes: 5 additions & 2 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
44 changes: 39 additions & 5 deletions test/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 })
Expand All @@ -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 })
Expand All @@ -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 })
Expand Down

0 comments on commit 2e560f1

Please sign in to comment.