https://github.com/chriscodex/integrations-tests-mongodbatlas-go
This repository can help you to integrate a MongoDBAtlas cluster database into your Go application and test the operations of creating, reading, updating, and deleting documents from a collection.
https://github.com/chriscodex/integrations-tests-mongodbatlas-go
database mongo mongodb nosql
Last synced: about 2 months ago
JSON representation
This repository can help you to integrate a MongoDBAtlas cluster database into your Go application and test the operations of creating, reading, updating, and deleting documents from a collection.
- Host: GitHub
- URL: https://github.com/chriscodex/integrations-tests-mongodbatlas-go
- Owner: chriscodex
- License: mit
- Created: 2022-07-08T15:00:22.000Z (almost 4 years ago)
- Default Branch: main
- Last Pushed: 2022-09-03T09:08:43.000Z (almost 4 years ago)
- Last Synced: 2025-09-01T13:05:04.867Z (10 months ago)
- Topics: database, mongo, mongodb, nosql
- Language: Go
- Homepage:
- Size: 18.6 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Integration Tests to MongoDBAtlas with Go  
This repository can help you to integrate a MongoDBAtlas cluster database into your Go application and test the operations of creating, reading, updating, and deleting documents from a collection.

---
## **Table of Contents** 📖
1. [Pre-Requirements](#pre-requirements-)
2. [Installation](#installation-)
3. [Run Tests](#run-tests-%EF%B8%8F)
---
### Pre-Requirements 📋
Have access to a MongoDBAtlas cluster.
In this link you have a guide on how to create it: https://www.mongodb.com/docs/atlas/tutorial/create-new-cluster/
---
### Installation 🔧
- Install the MongoDB driver as a dependency
```
go get go.mongodb.org/mongo-driver/mongo
```
- Inside the database folder, modify the `mongodb.con.go` file. Add the uri of your cluster and the name of your database
```
var (
// Add the uri of your cluster of MongoDBAtlas
// https://www.mongodb.com/docs/drivers/go/current/quick-start/#connect-to-your-cluster
uri = ""
// Add the name of your database
database = ""
)
```
---
### Run Tests ⚙️
To run the test, type this command:
```
go test
```
- To verify the connection, run the test inside `/database` directory.
- To test CRUD operations, run the test inside `/service/user.service` directory.
By default it will create the "users" collection, if you want to change the collection, modify the `user.repository.go` file located inside `/repositories/user.repository/`
```
// Name of collection
var collection = database.GetCollection("users")
```