Skip to main content


A sample application that get, create, update, and delete the data of a user in the database (MongoDB for this application).


  1. Go 1.16 or later
  2. Docker for running Keploy server
  3. Thunder Client / Postman Desktop Agent for testing localhost APIs
  4. Code Editor (VSCode, Sublime Text, etc.)


Navigate to Installation guide to quickly install and run the keploy server.

Start Users-Profile sample application

git clone
cd samples-go
cd users-profile
go get .
go run .


Sample Application Port: http://localhost:6789

  • /user : POST - Create a new user in the database
  • /user/:userId : GET - Get a user from the database
  • /user/:userId : PUT - Edit an existing user in the database
  • /user/:userId : DELETE - Delete an existing user from the database
  • /users : GET - Get all users from the database

Generate Test Cases

Keploy Port: http://localhost:6789/testlist

To generate Test Cases, you need to make some API calls. It could be using Thunder Client, Postman Desktop Agent, or your preferred API testing tool.

Once done, you can see the Test Cases on the Keploy server, like this:


Check the MongoDB database

To check the actual data being changed in the database. Open MongoDB Compass and enter the URI below to check the data.


NOTE: This is just a testing URI. Do not use it for public use. If you want, you can create your own MongoDB and add data to it.

The current URI might or might not work. It's better to setup your own MongoDB and connect it with the application. To do that, check the Setup your MongoDB section below.

Generate Test Runs

To generate Test Runs, close the application and run the below command:

go test -coverpkg=./... -covermode=atomic  ./...
test run completed
{"run id": "0e5f88eb-2746-40de-ab58-c0864ef869ee", "passed overall": false}
--- FAIL: TestKeploy (6.70s)
keploy.go:44: Keploy test suite failed
coverage: 100.0% of statements
FAIL users-profile 8.489s
? users-profile/configs [no test files]
? users-profile/controllers [no test files]
? users-profile/models [no test files]
? users-profile/responses [no test files]
? users-profile/routes [no test files]

Once done, you can see the Test Runs on the Keploy server, like this:

test-runs-ss1 test-runs-ss2 test-runs-ss3

Setup your MongoDB

Start with creating an account on MongoDB and follow the below steps:

Step 1: Create a New Project

Open the Project dropdown in the top-left corner and press the New Project button


Name your project and hit Next


If you wish to add members, you can add their email address, then press the Create Project button


Step 2: Create a Database

Click on Build a Database button


Choose the Shared plan and click Continue


Click Create Cluster, you can continue with the default cluster setup


Now, you have to create a user and setup network controls to access the database.

First, add a username and create a password, then hit Create User


Then you have to add the IP addresses with which you want to connect the cluster. You can continue by clicking on Add My Current IP Address then Finish and Close

Alternatively, you can add to let any IP address access the cluster.


Step 3: Connect with the Sample Application

Click on the Connect button


Choose the Connect your application option


Next, you have to select your driver and version.

In this sample application, we are using Go driver with 1.6 or later version. Once, you've entered the driver and version, copy the URI provided and close the popup.


Step 4: Add URI to code

Open the sample application in the code editor and open .env file


Create a variable MONGO-DB-URI in that file and paste the URI like this:


"To check the database, on MongoDB Compass, use this URI if you've setup your own MongoDB instead of the provided one."

Perfect! You've now connected the MongoDB with the sample application 🥳