https://github.com/bgildson/gomock-example
This repository contains some examples showing a progressive way to implement mocks.
https://github.com/bgildson/gomock-example
api client finalspace go golang mock tests
Last synced: 9 months ago
JSON representation
This repository contains some examples showing a progressive way to implement mocks.
- Host: GitHub
- URL: https://github.com/bgildson/gomock-example
- Owner: bgildson
- License: mit
- Created: 2021-06-12T14:58:53.000Z (about 5 years ago)
- Default Branch: master
- Last Pushed: 2021-06-15T18:55:13.000Z (about 5 years ago)
- Last Synced: 2024-06-20T08:17:17.705Z (about 2 years ago)
- Topics: api, client, finalspace, go, golang, mock, tests
- Language: Go
- Homepage:
- Size: 11.7 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
gomock-example
===
[](https://github.com/bgildson/gomock-example/actions/workflows/ci.yml)
[](https://coveralls.io/github/bgildson/gomock-example?branch=master)
[](https://goreportcard.com/report/github.com/bgildson/gomock-example)
This repository contains some examples showing a progressive way to implement mocks and use [gomock framework](https://github.com/golang/mock) to apply and autogen mocks.
## finalspace0
Is the [first example](client/finalspace0) and is the simplest implementation, it is only a code separation for request and parse response.
## finalspace1
Is the [second example](client/finalspace1) and, in comparation with the previous example, adds the dependency injection to specify the http client and api endpoint through parameters ensuring a more flexible use.
## finalspace2
Is the [third example](client/finalspace2) and it is equals to the previous implementation, in this example was incresed the tests and created a transport http mock to be possible uses the original http client and mock the response.
## finalspace3
Is the [fourth example](client/finalspace3) and was added a http client interface to replace the default http client struct and use a different function, the `Do`, to make the request, turning possible to use mockgen to generate a http client mock used to test the finalspace client.