Skip to content

Commit

Permalink
feat(repository-tests): run repository-tests on cloudant
Browse files Browse the repository at this point in the history
  • Loading branch information
Agnes Lin committed Nov 19, 2019
1 parent 2de28ef commit 7fabac1
Show file tree
Hide file tree
Showing 20 changed files with 2,028 additions and 3 deletions.
10 changes: 10 additions & 0 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,16 @@ matrix:
- npm run build -- --scope "@loopback/test-repository-postgresql" --include-dependencies
- psql -U postgres -a -f acceptance/repository-postgresql/test/schema.sql
- cd acceptance/repository-postgresql && npm run mocha
- node_js: "10"
os: linux
env:
- TASK=test-repository-cloudant
script:
# set up docker image and create admin for cloudant.
- npm run postinstall -- --scope "@loopback/test-repository-cloudant" --include-dependencies
- npm run build -- --scope "@loopback/test-repository-cloudant" --include-dependencies
- cd acceptance/repository-cloudant && npm run docker:setup
- source cloudant-config.sh && npm run mocha

branches:
only:
Expand Down
1 change: 1 addition & 0 deletions CODEOWNERS
Validating CODEOWNERS rules …
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

* @bajtos @raymondfeng

acceptance/repository-cloudant/* @agnes512
acceptance/repository-mongodb/* @bajtos
acceptance/repository-mysql/* @bajtos
acceptance/repository-postgresql/* @nabdelgadir
Expand Down
1 change: 1 addition & 0 deletions acceptance/repository-cloudant/.npmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
package-lock=true
Empty file.
25 changes: 25 additions & 0 deletions acceptance/repository-cloudant/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Copyright (c) IBM Corp. 2019. All Rights Reserved.
Node module: @loopback/test-repository-cloudant
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.
69 changes: 69 additions & 0 deletions acceptance/repository-cloudant/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# @loopback/test-repository-cloudant

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

## Running the test suite

### Using own Cloudant instance

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

**Linux & MacOS**

```bash
CLOUDANT_URL=<URL> CLOUDANT_HOST=<HOST> CLOUDANT_PORT=<PORT> CLOUDANT_USERNAME=<USER> CLOUDANT_PASSWORD=<PASSWORD> CLOUDANT_DATABASE=<DATABASE> npm test
```

**Windows**

```bash
SET CLOUDANT_URL=<URL>
SET CLOUDANT_HOST=<HOST>
SET CLOUDANT_PORT=<PORT>
SET CLOUDANT_USERNAME=<USER>
SET CLOUDANT_PASSWORD=<PASSWORD>
SET CLOUDANT_DATABASE=<DATABASE>
npm test
```

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

If you do not have a local Cloudant instance, you can also run the test suite
with very minimal requirements. We use couchDB docker image to run the test
locally.

NOTICE: we use `couchDB3` docker image for testing Cloudant because Cloudant
doesn't have a maintained image, and most of the their functionalities are the
same (except couchDB doesn't support geosearch).

- Install [Docker](https://docs.docker.com/engine/installation/).

- Run the following script

```bash
CLOUDANT_USERNAME=<USER> CLOUDANT_PASSWORD=<PASSWORD> CLOUDANT_DATABASE=<DATABASE> npm run docker:setup
```

This script will create a couchDB3 container and also set the admin/password for
you automatically.

- The script `cloudant-config.sh` is generated by the above script. It has all
needed environment variables. Run the following command to test out your code

```bash
source cloudant-config.sh && npm test
```

Those environment variables need to be exported to run the test. Or you have to
change them manually in `./src/__test__/cloudant.datasource.ts` file based on
the response you get from running the script `npm run docker:setup`.

## Contributors

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

## License

MIT
Loading

0 comments on commit 7fabac1

Please sign in to comment.