This repository contains some examples showing a progressive way to implement mocks and use gomock framework to apply and autogen mocks.
Is the first example and is the simplest implementation, it is only a code separation for request and parse response.
Is the second example 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.
Is the third example 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.
Is the fourth example 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.