gomock-example

command module
v0.0.0-...-1f7ca8e Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 15, 2021 License: MIT Imports: 4 Imported by: 0

README

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.

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis
client
finalspace3
Package finalspace3 is a generated GoMock package.
Package finalspace3 is a generated GoMock package.
pkg
net/http
Package http is a generated GoMock package.
Package http is a generated GoMock package.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL