Navigation Menu

Skip to content

Commit

Permalink
Make tests pass in github codespaces (#2437)
Browse files Browse the repository at this point in the history
* Make tests pass in github codespaces

There were a few tests which didn't specify a host or port which wasn't working well inside the codespaces docker environment.  Added host & port where required.  Also noticed one test wasn't actually _testing_, it was just `console.log`-ing its output, so I added proper assertions there.  Finally set `PGTESTNOSSL: true` in the codespaces environment until I can get the postgres docker container configured w/ SSL...which I will do l8r.

* lint
  • Loading branch information
brianc committed Dec 30, 2020
1 parent a109e8c commit daeafe8
Show file tree
Hide file tree
Showing 4 changed files with 9 additions and 4 deletions.
3 changes: 3 additions & 0 deletions .devcontainer/docker-compose.yml
Expand Up @@ -25,6 +25,9 @@ services:
PGUSER: user
PGDATABASE: data
PGHOST: db
# set this to true in the development environment until I can get SSL setup on the
# docker postgres instance
PGTESTNOSSL: true

# Overrides default command so things don't shut down after the process ends.
command: sleep infinity
Expand Down
@@ -1,3 +1,4 @@
const assert = require('assert')
const helper = require('../test-helper')
const suite = new helper.Suite()
const { Client } = helper.pg
Expand All @@ -8,6 +9,7 @@ suite.test('it sends options', async () => {
})
await client.connect()
const { rows } = await client.query('SHOW default_transaction_isolation')
console.log(rows)
assert.strictEqual(rows.length, 1)
assert.strictEqual(rows[0].default_transaction_isolation, 'serializable')
await client.end()
})
2 changes: 1 addition & 1 deletion packages/pg/test/integration/client/promise-api-tests.js
Expand Up @@ -20,7 +20,7 @@ suite.test('valid connection completes promise', () => {
})

suite.test('invalid connection rejects promise', (done) => {
const client = new pg.Client({ host: 'alksdjflaskdfj' })
const client = new pg.Client({ host: 'alksdjflaskdfj', port: 1234 })
return client.connect().catch((e) => {
assert(e instanceof Error)
done()
Expand Down
4 changes: 2 additions & 2 deletions packages/pg/test/integration/gh-issues/2079-tests.js
Expand Up @@ -32,7 +32,7 @@ let makeTerminatingBackend = (byte) => {

suite.test('SSL connection error allows event loop to exit', (done) => {
const port = makeTerminatingBackend('N')
const client = new helper.pg.Client({ ssl: 'require', port })
const client = new helper.pg.Client({ ssl: 'require', port, host: 'localhost' })
// since there was a connection error the client's socket should be closed
// and the event loop will have no refs and exit cleanly
client.connect((err) => {
Expand All @@ -43,7 +43,7 @@ suite.test('SSL connection error allows event loop to exit', (done) => {

suite.test('Non "S" response code allows event loop to exit', (done) => {
const port = makeTerminatingBackend('X')
const client = new helper.pg.Client({ ssl: 'require', port })
const client = new helper.pg.Client({ ssl: 'require', host: 'localhost', port })
// since there was a connection error the client's socket should be closed
// and the event loop will have no refs and exit cleanly
client.connect((err) => {
Expand Down

0 comments on commit daeafe8

Please sign in to comment.