1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-17 06:52:27 +01:00

running the tests: updated script & doc

This commit is contained in:
Sylvain 2020-06-23 14:24:30 +02:00
parent eb8ed8bf92
commit d419241323
3 changed files with 27 additions and 1 deletions

View File

@ -151,6 +151,13 @@ This procedure is not easy to follow so if you don't need to write some code for
18. Email notifications will be caught by MailCatcher.
To see the emails sent by the platform, open your web browser at `http://fabmanager-mailcatcher:1080` to access the MailCatcher interface.
<a name="tests"></a>
## Tests
Run the test suite with `./scripts/run-tests.sh`.
Pleas note: If you haven't set the Stripe's API keys in your `.env` file, the script will ask for them.
You must provide valid Stripe API **test keys** for the test suite to run.
<a name="postgresql"></a>
## PostgreSQL

View File

@ -8,6 +8,10 @@ ELASTICSEARCH_HOST=fabmanager-elastic
SECRET_KEY_BASE=83daf5e7b80d990f037407bab78dff9904aaf3c195a50f84fa8695a22287e707dfbd9524b403b1dcf116ae1d8c06844c3d7ed942564e5b46be6ae3ead93a9d30
# Stripe keys for tests
STRIPE_API_KEY=
STRIPE_PUBLISHABLE_KEY=
# Configure carefully!
DEFAULT_HOST=localhost:5000
DEFAULT_PROTOCOL=http

View File

@ -1,7 +1,22 @@
#!/usr/bin/env bash
# Use this script to safely run the test suite.
# This must be preferred over `rails test`.
stripe_public_key=$(RAILS_ENV='test' bin/rails runner "puts ENV['STRIPE_PUBLISHABLE_KEY']")
stripe_secret_key=$(RAILS_ENV='test' bin/rails runner "puts ENV['STRIPE_API_KEY']")
if [[ -z "$stripe_public_key" ]]; then
read -rp "STRIPE_PUBLISHABLE_KEY is not set. Please input the public key now. > " stripe_public_key </dev/tty
if [[ -z "$stripe_public_key" ]]; then echo "Key was not set, exiting..."; exit 1; fi
fi
if [[ -z "$stripe_secret_key" ]]; then
read -rp "STRIPE_API_KEY is not set. Please input the secret key now. > " stripe_secret_key </dev/tty
if [[ -z "$stripe_secret_key" ]]; then echo "Key was not set, exiting..."; exit 1; fi
fi
RAILS_ENV='test' bin/rails db:environment:set
RAILS_ENV='test' bin/rails db:drop
RAILS_ENV='test' bin/rails db:create
RAILS_ENV='test' bin/rails db:migrate
RAILS_ENV='test' bundle exec bin/rails test "$@"
STRIPE_PUBLISHABLE_KEY="$stripe_public_key" STRIPE_API_KEY="$stripe_secret_key" RAILS_ENV='test' bundle exec bin/rails test "$@"