test-backend 930 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950
  1. #!/usr/bin/env bash
  2. set -eu
  3. set -o pipefail
  4. function command_help() {
  5. echo "\
  6. $0 [-h|--help] IMAGE:TAG
  7. "
  8. }
  9. function error_msg() {
  10. echo ""
  11. echo "ERROR: $*"
  12. echo ""
  13. }
  14. function exit_msg() {
  15. error_msg "$@"
  16. command_help
  17. echo ""
  18. exit 1
  19. }
  20. case "$1" in
  21. mongo|mongodb)
  22. docker-compose run --rm -d mongo
  23. sleep 2
  24. function finish() {
  25. docker rm -f persistent_mongo_run_1
  26. }
  27. trap finish EXIT
  28. stack test persistent-mongodb
  29. ;;
  30. postgresql|postgres)
  31. docker-compose run --rm -d postgres
  32. sleep 2
  33. function finish() {
  34. docker rm -f persistent_postgres_run_1 || {
  35. echo "startup failure"
  36. exit 1
  37. }
  38. }
  39. trap finish EXIT
  40. stack test persistent-postgresql
  41. ;;
  42. *)
  43. exit_msg "don't yet know how to test: $1, please teach me!"
  44. ;;
  45. esac