-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4b5b537
commit 85d1a10
Showing
9 changed files
with
1,876 additions
and
240 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
name: Test | ||
|
||
on: | ||
push: | ||
branches: | ||
- main | ||
- setup-ci # TODO: Remove | ||
pull_request: | ||
branches: | ||
- main | ||
|
||
jobs: | ||
test: | ||
name: Node.js ${{ matrix.node }} + PostgreSQL ${{ matrix.postgres }} | ||
runs-on: ubuntu-latest | ||
strategy: | ||
fail-fast: false | ||
matrix: | ||
node: | ||
- 16 | ||
- 18 | ||
- 20 | ||
postgres: | ||
- 13 | ||
- 14 | ||
- 15 | ||
- 16 | ||
services: | ||
postgres: | ||
image: postgres:${{ matrix.postgres }} | ||
options: >- | ||
--health-cmd pg_isready | ||
--health-interval 10s | ||
--health-timeout 5s | ||
--health-retries 5 | ||
ports: | ||
- 5432:5432 | ||
timeout-minutes: 10 | ||
steps: | ||
- uses: actions/checkout@v4 | ||
- uses: actions/setup-node@v4 | ||
with: | ||
node-version: ${{ matrix.node }} | ||
- name: Install | ||
run: npm install | ||
- name: Test | ||
run: npm test |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module.exports = { | ||
timeout: 5_000, | ||
file: './test/setup.js', | ||
spec: '**/*.spec.js', | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
{ | ||
// Use IntelliSense to learn about possible attributes. | ||
// Hover to view descriptions of existing attributes. | ||
// For more information, visit: https://go.microsoft.com/fwlink/?linkid=830387 | ||
"version": "0.2.0", | ||
"configurations": [ | ||
{ | ||
"name": "Test", | ||
"type": "node", | ||
"request": "launch", | ||
"program": "${workspaceRoot}/node_modules/mocha/bin/_mocha", | ||
"stopOnEntry": false, | ||
"args": [ | ||
"--no-timeouts", | ||
"--colors", | ||
], | ||
"cwd": "${workspaceRoot}", | ||
"runtimeExecutable": null, | ||
"env": {}, | ||
"sourceMaps": true | ||
}, | ||
] | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
const PostgresDB = require('.'); | ||
const {Pool} = require('pg'); | ||
const fs = require('node:fs'); | ||
|
||
const DB_NAME = 'sharedbtest'; | ||
|
||
function create(callback) { | ||
var db = new PostgresDB({database: DB_NAME}); | ||
callback(null, db); | ||
}; | ||
|
||
describe('PostgresDB', function() { | ||
let pool; | ||
let client; | ||
|
||
beforeEach(async () => { | ||
pool = new Pool({database: 'postgres'}); | ||
client = await pool.connect(); | ||
await client.query(`DROP DATABASE IF EXISTS ${DB_NAME}`); | ||
await client.query(`CREATE DATABASE ${DB_NAME}`); | ||
|
||
const testPool = new Pool({database: DB_NAME}); | ||
const testClient = await testPool.connect(); | ||
const structure = fs.readFileSync('./structure.sql', 'utf8'); | ||
await testClient.query(structure); | ||
await testClient.release(true); | ||
await testPool.end(); | ||
}); | ||
|
||
afterEach(async function() { | ||
await client.query(`DROP DATABASE IF EXISTS ${DB_NAME}`); | ||
await client.release(true); | ||
await pool.end(); | ||
}); | ||
|
||
require('sharedb/test/db')({create: create}); | ||
}); |
Oops, something went wrong.