This guide outlines the steps to test the Personality API implemented in NestJS using either a MongoDB or PostgreSQL database.
Ensure you have the following installed on your machine:
- Docker
- Docker Compose
- Node.js
- Yarn (or npm)
- Clone the repository to your local machine.
- Navigate to the project directory.
-
Start the databases using Docker Compose:
docker-compose up -d
-
Install the project dependencies:
yarn install
-
Start the NestJS server with the desired database type using the
DB_TYPE
environment variable. For MongoDB:DB_TYPE=mongodb yarn start
For PostgreSQL:
DB_TYPE=postgresql yarn start
The server will start and connect to the specified database.
-
Open a new terminal and navigate to the project directory.
-
Execute the testing script:
./test.sh
The script will send a series of HTTP requests to the API to test CRUD operations for the
Personality
model. -
Observe the output of the script to verify the API's behavior.
-
Stop the server using
Ctrl + C
, and repeat steps 1-4 for the other database type by updating theDB_TYPE
environment variable, restarting the server, and running the script again.
-
Stop the Docker containers:
docker-compose down
This concludes the testing guide for the Personality API.