Page Contents

@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

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

Windows

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.

  • Run the following script

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
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.

License

MIT