Skip to content

Commit

Permalink
feat(test-repository-postgresql): run repository tests for postgresql
Browse files Browse the repository at this point in the history
  • Loading branch information
nabdelgadir committed Oct 9, 2019
1 parent 5b4569a commit ce4337c
Show file tree
Hide file tree
Showing 21 changed files with 1,061 additions and 45 deletions.
14 changes: 14 additions & 0 deletions .travis.yml
Expand Up @@ -67,6 +67,20 @@ matrix:
- npm run postinstall -- --scope "@loopback/test-repository-mysql" --include-filtered-dependencies
- npm run build -- --scope "@loopback/test-repository-mysql" --include-filtered-dependencies
- cd acceptance/repository-mysql && npm run mocha
- node_js: "10"
os: linux
env:
- TASK=test-repository-postgresql
- POSTGRESQL_USER=postgres
services:
- postgresql
script:
- npm run postinstall -- --scope "@loopback/test-repository-postgresql" --include-filtered-dependencies
- npm run build -- --scope "@loopback/test-repository-postgresql" --include-filtered-dependencies
- psql -U postgres -c "CREATE DATABASE repository_tests;"
- psql -U postgres -c "CREATE DATABASE repository_tests_new;"
- psql -U postgres -c "\c repository_tests;"
- cd acceptance/repository-postgresql && npm run mocha

branches:
only:
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Expand Up @@ -8,6 +8,7 @@

acceptance/repository-mongodb/* @bajtos
acceptance/repository-mysql/* @bajtos
acceptance/repository-postgresql/* @nabdelgadir

packages/authentication/* @bajtos @raymondfeng
packages/boot/* @raymondfeng @hacksparrow
Expand Down
2 changes: 1 addition & 1 deletion acceptance/repository-mongodb/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@loopback/test-repository-mongodb",
"version": "0.4.8",
"description": "",
"private": "true",
"private": true,
"engines": {
"node": ">=8.9"
},
Expand Down
@@ -1,5 +1,5 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/test-repository-mysql
// Node module: @loopback/test-repository-mongodb
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

Expand Down
2 changes: 1 addition & 1 deletion acceptance/repository-mysql/package.json
Expand Up @@ -2,7 +2,7 @@
"name": "@loopback/test-repository-mysql",
"version": "0.4.8",
"description": "",
"private": "true",
"private": true,
"engines": {
"node": ">=8.9"
},
Expand Down
1 change: 1 addition & 0 deletions acceptance/repository-postgresql/.npmrc
@@ -0,0 +1 @@
package-lock=true
Empty file.
25 changes: 25 additions & 0 deletions acceptance/repository-postgresql/LICENSE
@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2019. All Rights Reserved.
Node module: @loopback/test-repository-postgresql
This project is licensed under the MIT License, full text below.

--------

MIT license

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
66 changes: 66 additions & 0 deletions acceptance/repository-postgresql/README.md
@@ -0,0 +1,66 @@
# @loopback/test-repository-postgresql

Acceptance tests for `@loopback/repository` + `loopback-connector-postgresql`.

## Running the test suite

### Using own PostgreSQL instance

If you have a local PostgreSQL instance listening on `localhost` and the default
port, with a `root` user and an empty password, use the following command:

```bash
npm test
```

If you have a local or remote PostgreSQL instance and would like to use that to
run the test suite, use the following command:

**Linux & MacOS**

```bash
POSTGRESQL_HOST=<HOST> POSTGRESQL_PORT=<PORT> POSTGRESQL_USER=<USER> POSTGRESQL_PASSWORD=<PASSWORD> POSTGRESQL_DATABASE=<DATABASE> npm test
```

**Windows**

```bash
SET POSTGRESQL_HOST=<HOST>
SET POSTGRESQL_PORT=<PORT>
SET POSTGRESQL_USER=<USER>
SET POSTGRESQL_PASSWORD=<PASSWORD>
SET POSTGRESQL_DATABASE=<DATABASE>
npm test
```

### Using Docker (Linux, MacOS, WSL)

If you do not have a local PostgreSQL instance, you can also run the test suite
with very minimal requirements.

- Assuming you have [Docker](https://docs.docker.com/engine/installation/)
installed, run the following script which would spawn a PostgreSQL instance on
your local:

```bash
source setup.sh <HOST> <PORT> <USER> <PASSWORD> <DATABASE>
```

Where `<HOST>`, `<PORT>`, `<USER>`, `<PASSWORD>` and `<DATABASE>` are optional
parameters. The default values are `localhost`, `5432`, `root`, `pass` and
`testdb` respectively.

- Run the test:

```bash
npm test
```

## Contributors

See
[all contributors](https://github.com/strongloop/loopback-next/graphs/contributors).

## License

MIT
6 changes: 6 additions & 0 deletions acceptance/repository-postgresql/index.d.ts
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/test-repository-postgresql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

export * from './dist';
6 changes: 6 additions & 0 deletions acceptance/repository-postgresql/index.js
@@ -0,0 +1,6 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/test-repository-postgresql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

module.exports = require('./dist');
8 changes: 8 additions & 0 deletions acceptance/repository-postgresql/index.ts
@@ -0,0 +1,8 @@
// Copyright IBM Corp. 2019. All Rights Reserved.
// Node module: @loopback/test-repository-postgresql
// This file is licensed under the MIT License.
// License text available at https://opensource.org/licenses/MIT

// DO NOT EDIT THIS FILE
// Add any additional (re)exports to src/index.ts instead.
export * from './src';

0 comments on commit ce4337c

Please sign in to comment.