Testing our server-to-server communication with bash
To run our test, we essentially need to spin up out database, auth server, and to-do server. We then must run a HTTP request to create the user, login, and then create a to-do item. If we can create the to-do item, we know that the communication between both servers work, because we must call the authentication server to get the user ID to create the to-do item.
To run our test, we first must create the following .env
file:
# nanoservices/to_do/.env
TO_DO_DB_URL=postgres://username:password@localhost/to_do
AUTH_DB_URL=postgres://username:password@localhost/to_do
AUTH_API_URL=http://127.0.0.1:8081
JWT_SECRET=secret
Now that we have the environment variables that are needed, we can start with the boilerplate code for our testing bash script with the following code:
#!/usr/bin/env bash
# nanoservices/to_do/scripts/test_server_com.sh
SCRIPTPATH="$( cd "$(dirname "$0")" ; pwd -P )"
cd $SCRIPTPATH
cd ../....