diff --git a/.github/workflows/ci.yaml b/.github/workflows/ci.yaml index 9cb6c00..e6a3196 100644 --- a/.github/workflows/ci.yaml +++ b/.github/workflows/ci.yaml @@ -1,4 +1,4 @@ -name: GitHub CI +name: CI workflow on: [push, pull_request] @@ -7,7 +7,7 @@ jobs: runs-on: ubuntu-latest strategy: matrix: - node: [6, 8, 10, 12, 13] + node: [10, 12, 14] name: Node.js ${{ matrix.node }} @@ -17,6 +17,7 @@ jobs: env: POSTGRES_USER: postgres POSTGRES_DB: postgres + POSTGRES_PASSWORD: postgres ports: # will assign a random free host port - 5432:5432 @@ -32,7 +33,8 @@ jobs: run: | npm i node-gyp sudo apt-get install -yqq libpq-dev postgresql-client - psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres + chmod 600 .pgpass + PGPASSFILE=.pgpass psql -h localhost -p ${{ job.services.postgres.ports[5432] }} -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres - name: Install run: npm install diff --git a/.pgpass b/.pgpass new file mode 100644 index 0000000..e7aebce --- /dev/null +++ b/.pgpass @@ -0,0 +1 @@ +localhost:*:*:postgres:postgres \ No newline at end of file diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index 50e55da..0000000 --- a/.travis.yml +++ /dev/null @@ -1,27 +0,0 @@ -language: node_js - -dist: xenial - -node_js: - - "12" - - "10" - - "8" - - "6" - -services: - - postgresql - -sudo: true - -before_install: - - psql -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres - - if [ $TRAVIS_OS_NAME == "linux" ]; then - if [[ $(node -v) =~ v[1-9][0-9] ]]; then - source ./ci_scripts/build.sh; - fi - fi - -notifications: - email: - on_success: never - on_failure: always diff --git a/package.json b/package.json index 1081cf3..477f03b 100644 --- a/package.json +++ b/package.json @@ -7,8 +7,8 @@ "test": "standard && tap -J test/*.test.js", "test:report": "standard && tap -J --coverage-report=html test/*.test.js", "test:verbose": "standard && tap -J test/*.test.js -Rspec", - "load-data": "docker run --rm -d --link fastify-postgres:postgres postgres:11-alpine psql -h postgres -d postgres -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres", - "postgres": "docker run --rm -d -p 5432:5432 --name fastify-postgres postgres:11-alpine" + "postgres": "docker run -p 5432:5432 --name fastify-postgres -e POSTGRES_PASSWORD=postgres -d postgres:11-alpine", + "load-data": "docker exec -it fastify-postgres psql -c 'CREATE TABLE users(id serial PRIMARY KEY, username VARCHAR (50) NOT NULL);' -U postgres -d postgres" }, "repository": { "type": "git", @@ -29,10 +29,10 @@ }, "homepage": "https://github.com/fastify/fastify-postgres#readme", "dependencies": { - "fastify-plugin": "^1.5.0" + "fastify-plugin": "^2.0.0" }, "devDependencies": { - "fastify": "^2.7.1", + "fastify": "^3.0.0-rc.1", "pg": "*", "pg-native": "^3.0.0", "standard": "^13.0.1", @@ -40,10 +40,5 @@ }, "peerDependencies": { "pg": ">=6.0.0" - }, - "greenkeeper": { - "ignore": [ - "tap" - ] } } diff --git a/test/initialization.test.js b/test/initialization.test.js index 169dc4d..011bef1 100644 --- a/test/initialization.test.js +++ b/test/initialization.test.js @@ -12,7 +12,7 @@ test('Should be able to use native module', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', native: true }) @@ -38,7 +38,7 @@ test('Should be able to use an alternative pg module', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', pg: altPg }) @@ -64,7 +64,7 @@ test('Should not throw if registered within different scopes (with and without n fastify.register(function scopeOne (instance, opts, next) { instance.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) next() @@ -72,12 +72,12 @@ test('Should not throw if registered within different scopes (with and without n fastify.register(function scopeTwo (instance, opts, next) { instance.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'one' }) instance.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'two' }) @@ -97,11 +97,11 @@ test('Should throw when trying to register multiple instances without giving a n t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -119,13 +119,13 @@ test('Should throw when trying to register duplicate connection names', (t) => { fastify .register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', - name - }) - .register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name }) + fastify.register(fastifyPostgres, { + connectionString: 'postgres://postgres:postgres@localhost/postgres', + name + }) fastify.ready((err) => { t.ok(err) @@ -140,7 +140,7 @@ test('fastify.pg namespace should exist', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -160,7 +160,7 @@ test('fastify.pg.test namespace should exist', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) diff --git a/test/query.test.js b/test/query.test.js index 5af59b4..2209cdb 100644 --- a/test/query.test.js +++ b/test/query.test.js @@ -13,7 +13,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -40,7 +40,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -60,7 +60,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -88,7 +88,7 @@ test('When fastify.pg root namespace is used:', (t) => { const DB_NAME = 'database_that_do_not_exist' fastify.register(fastifyPostgres, { - connectionString: `postgres://postgres@localhost/${DB_NAME}` + connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}` }) fastify.ready((err) => { @@ -112,7 +112,7 @@ test('When fastify.pg root namespace is used:', (t) => { const DB_NAME = 'database_that_do_not_exist' fastify.register(fastifyPostgres, { - connectionString: `postgres://postgres@localhost/${DB_NAME}` + connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}` }) fastify.ready((err) => { @@ -141,7 +141,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -167,7 +167,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -187,7 +187,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -212,7 +212,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test', native: true }) @@ -240,7 +240,7 @@ test('When fastify.pg.test namespace is used:', (t) => { const DB_NAME = 'database_that_do_not_exist' fastify.register(fastifyPostgres, { - connectionString: `postgres://postgres@localhost/${DB_NAME}`, + connectionString: `postgres://postgres:postgres@localhost/${DB_NAME}`, name: 'test' }) diff --git a/test/transaction.test.js b/test/transaction.test.js index 2646f52..fcc1b97 100644 --- a/test/transaction.test.js +++ b/test/transaction.test.js @@ -13,7 +13,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -50,7 +50,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -87,7 +87,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -128,7 +128,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -182,7 +182,7 @@ test('When fastify.pg root namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres' + connectionString: 'postgres://postgres:postgres@localhost/postgres' }) fastify.ready((err) => { @@ -234,7 +234,7 @@ test('When fastify.pg root namespace is used:', (t) => { const BAD_DB_NAME = 'db_that_does_not_exist' fastify.register(fastifyPostgres, { - connectionString: `postgres://postgres@localhost/${BAD_DB_NAME}` + connectionString: `postgres://postgres:postgres@localhost/${BAD_DB_NAME}` }) fastify.ready((err) => { @@ -259,7 +259,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -297,7 +297,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -337,7 +337,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -380,7 +380,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -435,7 +435,7 @@ test('When fastify.pg.test namespace is used:', (t) => { t.teardown(() => fastify.close()) fastify.register(fastifyPostgres, { - connectionString: 'postgres://postgres@localhost/postgres', + connectionString: 'postgres://postgres:postgres@localhost/postgres', name: 'test' }) @@ -488,7 +488,7 @@ test('When fastify.pg.test namespace is used:', (t) => { const BAD_DB_NAME = 'db_that_does_not_exist' fastify.register(fastifyPostgres, { - connectionString: `postgres://postgres@localhost/${BAD_DB_NAME}`, + connectionString: `postgres://postgres:postgres@localhost/${BAD_DB_NAME}`, name: 'test' })