Documentation ¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type CacheSvc ¶
type CacheSvc struct { // GetFunc mocks the Get method. GetFunc func(key string, fn func() (interface{}, error)) (interface{}, error) // contains filtered or unexported fields }
CacheSvc is a mock implementation of cache.Service.
func TestSomethingThatUsesService(t *testing.T) { // make and configure a mocked cache.Service mockedService := &CacheSvc{ GetFunc: func(key string, fn func() (interface{}, error)) (interface{}, error) { panic("mock out the Get method") }, } // use mockedService in code that requires cache.Service // and then make assertions. }
func (*CacheSvc) GetCalls ¶
GetCalls gets all the calls that were made to Get. Check the length with:
len(mockedService.GetCalls())
func (*CacheSvc) ResetCalls ¶ added in v0.2.0
func (mock *CacheSvc) ResetCalls()
ResetCalls reset all the calls that were made to all mocked methods.
func (*CacheSvc) ResetGetCalls ¶ added in v0.2.0
func (mock *CacheSvc) ResetGetCalls()
ResetGetCalls reset all the calls that were made to Get.
type CircuitBreakerSvcMock ¶
type CircuitBreakerSvcMock struct { // ExecuteFunc mocks the Execute method. ExecuteFunc func(req func() (interface{}, error)) (interface{}, error) // contains filtered or unexported fields }
CircuitBreakerSvcMock is a mock implementation of middleware.CircuitBreakerSvc.
func TestSomethingThatUsesCircuitBreakerSvc(t *testing.T) { // make and configure a mocked middleware.CircuitBreakerSvc mockedCircuitBreakerSvc := &CircuitBreakerSvcMock{ ExecuteFunc: func(req func() (interface{}, error)) (interface{}, error) { panic("mock out the Execute method") }, } // use mockedCircuitBreakerSvc in code that requires middleware.CircuitBreakerSvc // and then make assertions. }
func (*CircuitBreakerSvcMock) Execute ¶
func (mock *CircuitBreakerSvcMock) Execute(req func() (interface{}, error)) (interface{}, error)
Execute calls ExecuteFunc.
func (*CircuitBreakerSvcMock) ExecuteCalls ¶
func (mock *CircuitBreakerSvcMock) ExecuteCalls() []struct { Req func() (interface{}, error) }
ExecuteCalls gets all the calls that were made to Execute. Check the length with:
len(mockedCircuitBreakerSvc.ExecuteCalls())
func (*CircuitBreakerSvcMock) ResetCalls ¶ added in v0.2.0
func (mock *CircuitBreakerSvcMock) ResetCalls()
ResetCalls reset all the calls that were made to all mocked methods.
func (*CircuitBreakerSvcMock) ResetExecuteCalls ¶ added in v0.2.0
func (mock *CircuitBreakerSvcMock) ResetExecuteCalls()
ResetExecuteCalls reset all the calls that were made to Execute.
type LoggerSvc ¶
type LoggerSvc struct { // LogfFunc mocks the Logf method. LogfFunc func(format string, args ...interface{}) // contains filtered or unexported fields }
LoggerSvc is a mock implementation of logger.Service.
func TestSomethingThatUsesService(t *testing.T) { // make and configure a mocked logger.Service mockedService := &LoggerSvc{ LogfFunc: func(format string, args ...interface{}) { panic("mock out the Logf method") }, } // use mockedService in code that requires logger.Service // and then make assertions. }
func (*LoggerSvc) LogfCalls ¶
LogfCalls gets all the calls that were made to Logf. Check the length with:
len(mockedService.LogfCalls())
func (*LoggerSvc) ResetCalls ¶ added in v0.2.0
func (mock *LoggerSvc) ResetCalls()
ResetCalls reset all the calls that were made to all mocked methods.
func (*LoggerSvc) ResetLogfCalls ¶ added in v0.2.0
func (mock *LoggerSvc) ResetLogfCalls()
ResetLogfCalls reset all the calls that were made to Logf.
type RepeaterSvcMock ¶
type RepeaterSvcMock struct { // DoFunc mocks the Do method. DoFunc func(ctx context.Context, fun func() error, errs ...error) error // contains filtered or unexported fields }
RepeaterSvcMock is a mock implementation of middleware.RepeaterSvc.
func TestSomethingThatUsesRepeaterSvc(t *testing.T) { // make and configure a mocked middleware.RepeaterSvc mockedRepeaterSvc := &RepeaterSvcMock{ DoFunc: func(ctx context.Context, fun func() error, errs ...error) error { panic("mock out the Do method") }, } // use mockedRepeaterSvc in code that requires middleware.RepeaterSvc // and then make assertions. }
func (*RepeaterSvcMock) DoCalls ¶
func (mock *RepeaterSvcMock) DoCalls() []struct { Ctx context.Context Fun func() error Errs []error }
DoCalls gets all the calls that were made to Do. Check the length with:
len(mockedRepeaterSvc.DoCalls())
func (*RepeaterSvcMock) ResetCalls ¶ added in v0.2.0
func (mock *RepeaterSvcMock) ResetCalls()
ResetCalls reset all the calls that were made to all mocked methods.
func (*RepeaterSvcMock) ResetDoCalls ¶ added in v0.2.0
func (mock *RepeaterSvcMock) ResetDoCalls()
ResetDoCalls reset all the calls that were made to Do.
type RoundTripper ¶
type RoundTripper struct { RoundTripFunc func(*http.Request) (*http.Response, error) // contains filtered or unexported fields }
RoundTripper mock to test other middlewares
func (*RoundTripper) Calls ¶
func (r *RoundTripper) Calls() int
Calls returns how many time RoundTrip func called
func (*RoundTripper) ResetCalls ¶ added in v0.2.0
func (r *RoundTripper) ResetCalls()
ResetCalls resets calls counter