Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pthethanh/testing-mongodb-with-gomock
demonstrate mocking mongodb with gomock
https://github.com/pthethanh/testing-mongodb-with-gomock
go golang mock mongodb testing
Last synced: 9 days ago
JSON representation
demonstrate mocking mongodb with gomock
- Host: GitHub
- URL: https://github.com/pthethanh/testing-mongodb-with-gomock
- Owner: pthethanh
- License: mit
- Created: 2018-10-08T06:46:38.000Z (about 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-08T07:36:05.000Z (about 6 years ago)
- Last Synced: 2024-06-09T10:41:53.538Z (5 months ago)
- Topics: go, golang, mock, mongodb, testing
- Language: Go
- Size: 4.88 KB
- Stars: 6
- Watchers: 3
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# testing-mongodb-with-gomock
This is a demonstration of mocking MongoDB with [gomock](https://github.com/golang/mock).## Get the code and run the test :)
**Get it:** `go get -u github.com/golovers/testing-mongodb-with-gomock`
**Run it**: `go test -v pkg/users/*`
**Result**:```
=== RUN TestMongoDB
=== PAUSE TestMongoDB
=== RUN TestAddUser
=== PAUSE TestAddUser
=== RUN TestGetUserEmptyResponse
=== PAUSE TestGetUserEmptyResponse
=== RUN TestGetUserNonEmptyResponse
=== PAUSE TestGetUserNonEmptyResponse
=== CONT TestMongoDB
=== CONT TestGetUserNonEmptyResponse
=== CONT TestGetUserEmptyResponse
--- PASS: TestGetUserNonEmptyResponse (0.00s)
--- PASS: TestMongoDB (0.00s)
=== CONT TestAddUser
--- PASS: TestAddUser (0.00s)
--- PASS: TestGetUserEmptyResponse (0.00s)
PASS
ok command-line-arguments (cached)
```