Skip to content

This repository contains some examples showing a progressive way to implement mocks.

License

Notifications You must be signed in to change notification settings

bgildson/gomock-example

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gomock-example

Test Status Coverage Status Go Report Card

This repository contains some examples showing a progressive way to implement mocks and use gomock framework to apply and autogen mocks.

finalspace0

Is the first example and is the simplest implementation, it is only a code separation for request and parse response.

finalspace1

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.

finalspace2

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.

finalspace3

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.

About

This repository contains some examples showing a progressive way to implement mocks.

Topics

Resources

License

Stars

Watchers

Forks