Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/edmartt/go-testing-mocks
This project is for learning about mocking external services calls
https://github.com/edmartt/go-testing-mocks
go golang mock mocking solid-principles sqlite3 unit-test unit-testing vertical-slice-architecture
Last synced: 1 day ago
JSON representation
This project is for learning about mocking external services calls
- Host: GitHub
- URL: https://github.com/edmartt/go-testing-mocks
- Owner: Edmartt
- License: gpl-2.0
- Created: 2022-05-28T16:37:13.000Z (over 2 years ago)
- Default Branch: main
- Last Pushed: 2022-05-28T17:11:47.000Z (over 2 years ago)
- Last Synced: 2024-12-06T14:46:52.502Z (about 2 months ago)
- Topics: go, golang, mock, mocking, solid-principles, sqlite3, unit-test, unit-testing, vertical-slice-architecture
- Language: Go
- Homepage:
- Size: 28.3 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# GO-TESTING-MOCKS
The main purpose of this project is understanding the importance of knowing about what to do
when our services main core depends on third party services like http services, databases, etc.For reaching our goal of testing the service layer we make use of mocks. With a mock we can replace those third parties services calls
with our own logic according to the data we expect from those services.### Running Project
1.
```
go mod download
```or
```
go mod tidy
```2.
```
go run main.go
```
When the project is running a hardcoded user will be created in a SQLite database. If we run the project again with the same
hardcoded user we'll have an error of nil because the CreateUser function has a check in case the user already exists.### Running Unit Test with a Coverage file as Output
```
go test -v --coverprofile=coverage.out ./... ./...
```### Watching the coverage in browser
```
go tool cover -html=coverage.out
```