A sample app
git clone https://github.com/keploy/samples-go.git && cd samples-go/go-jwt
go mod downloadInstall keploy via one-click:-
curl --silent -O -L https://keploy.io/install.sh && source install.shdocker compose up -d dbNow, we will create the binary of our application:-
go build .Once we have our binary file ready,this command will start the recording of API calls using ebpf:-
sudo -E keploy record -c "./go-jwt"Make API Calls using Hoppscotch, Postman or cURL command. Keploy with capture those calls to generate the test-suites containing testcases and data mocks.
To genereate testcases we just need to make some API calls. You can use Postman, Hoppscotch, or simply curl
- Generate shortned url
curl --request GET \
--url http://localhost:8000/health \
--header 'Accept: */*' \
--header 'Host: localhost:8000' \
--header 'User-Agent: curl/7.81.0' this will return the response.
{"status": "healthy"}
- Fetch the Products
curl --request GET \
--url http://localhost:8000/generate-token?expiry=15 \
--header 'Host: localhost:8000' \
--header 'User-Agent: curl/7.81.0' \
--header 'Accept: */*' we will get output:
{"token":"<your_jwt_token>"}- Fetch a single product
curl --request GET \
--url http://localhost:8000/check-token?token=<your_jwt_token> \
--header 'Accept: */*' \
--header 'Host: localhost:8000' \
--header 'User-Agent: curl/7.81.0' we will get output:-
{"username" : "example_user"}Now, since these API calls were captured as editable testcases and written to keploy/tests folder. The keploy directory would also have mocks files that contains all the outputs.
Now let's run the test mode (in the mux-sql directory, not the Keploy directory).
sudo -E keploy test -c "./go-jwt" --delay 10Once done, you can see the Test Runs on the Keploy server, like this:

