A sample application that get, create, update, and delete the data of a user in the database: -
git clone https://github.com/keploy/samples-go && cd fasthttp-postgres
curl --silent -O -L https://keploy.io/install.sh && source install.shKeploy can be used on Linux, Windows and MacOS through Docker.
Note: To run Keploy on MacOS through Docker the version must be
4.25.2or above.
keploy record -c "docker compose up" --container-name=fasthttp_appTo genereate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl: -
curl -X POST -H "Content-Type: application/json" -d '{"name":"Author Name"}' http://localhost:8080/authorscurl -X POST -H "Content-Type: application/json" -d '{"title":"Book Title","author_id":1}' http://localhost:8080/bookscurl -i http://localhost:8080/booksNow that we have our testcase captured, run the test file.
keploy test -c "docker compose up" --container-name=fasthttp_app --delay 10Note: This application requires the following database environment variables to be set in order to run correctly.
Create a .env file in this directory with the following values:
DB_HOST=localhost DB_PORT=5432 DB_USER=postgres DB_PASSWORD=password DB_NAME=db
docker compose up -d postgresgo build -o appkeploy record -c "./app"Note: The server would be running on http://localhost:8080
To genereate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl: -
curl -X POST -H "Content-Type: application/json" -d '{"name":"Author Name"}' http://localhost:8080/authorscurl -X POST -H "Content-Type: application/json" -d '{"title":"Book Title","author_id":1}' http://localhost:8080/bookscurl -i http://localhost:8080/booksNow that we have our testcase captured, run the test file.
keploy test -c "./app" --delay 10Voila! Our testcases have passed🥳 . We can also notice that by capturing just few API calls we got around 88.5% of aggregated coverage with keploy generated testcases
If you like the sample application, Don't forget to star us ✨

