Documentation
¶
Index ¶
- type HTTPServerMock
- type HealthCheckerMock
- func (mock *HealthCheckerMock) AddAndGetCheck(name string, checker healthcheck.Checker) (*healthcheck.Check, error)
- func (mock *HealthCheckerMock) AddAndGetCheckCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
- func (mock *HealthCheckerMock) HandlerCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Start(ctx context.Context)
- func (mock *HealthCheckerMock) StartCalls() []struct{ ... }
- func (mock *HealthCheckerMock) Stop()
- func (mock *HealthCheckerMock) StopCalls() []struct{}
- func (mock *HealthCheckerMock) Subscribe(s healthcheck.Subscriber, checks ...*healthcheck.Check)
- func (mock *HealthCheckerMock) SubscribeCalls() []struct{ ... }
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HTTPServerMock ¶
type HTTPServerMock struct {
// ListenAndServeFunc mocks the ListenAndServe method.
ListenAndServeFunc func() error
// ShutdownFunc mocks the Shutdown method.
ShutdownFunc func(ctx context.Context) error
// contains filtered or unexported fields
}
HTTPServerMock is a mock implementation of service.HTTPServer.
func TestSomethingThatUsesHTTPServer(t *testing.T) {
// make and configure a mocked service.HTTPServer
mockedHTTPServer := &HTTPServerMock{
ListenAndServeFunc: func() error {
panic("mock out the ListenAndServe method")
},
ShutdownFunc: func(ctx context.Context) error {
panic("mock out the Shutdown method")
},
}
// use mockedHTTPServer in code that requires service.HTTPServer
// and then make assertions.
}
func (*HTTPServerMock) ListenAndServe ¶
func (mock *HTTPServerMock) ListenAndServe() error
ListenAndServe calls ListenAndServeFunc.
func (*HTTPServerMock) ListenAndServeCalls ¶
func (mock *HTTPServerMock) ListenAndServeCalls() []struct { }
ListenAndServeCalls gets all the calls that were made to ListenAndServe. Check the length with:
len(mockedHTTPServer.ListenAndServeCalls())
func (*HTTPServerMock) Shutdown ¶
func (mock *HTTPServerMock) Shutdown(ctx context.Context) error
Shutdown calls ShutdownFunc.
func (*HTTPServerMock) ShutdownCalls ¶
func (mock *HTTPServerMock) ShutdownCalls() []struct { Ctx context.Context }
ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:
len(mockedHTTPServer.ShutdownCalls())
type HealthCheckerMock ¶
type HealthCheckerMock struct {
// AddAndGetCheckFunc mocks the AddAndGetCheck method.
AddAndGetCheckFunc func(name string, checker healthcheck.Checker) (*healthcheck.Check, error)
// HandlerFunc mocks the Handler method.
HandlerFunc func(w http.ResponseWriter, req *http.Request)
// StartFunc mocks the Start method.
StartFunc func(ctx context.Context)
// StopFunc mocks the Stop method.
StopFunc func()
// SubscribeFunc mocks the Subscribe method.
SubscribeFunc func(s healthcheck.Subscriber, checks ...*healthcheck.Check)
// contains filtered or unexported fields
}
HealthCheckerMock is a mock implementation of service.HealthChecker.
func TestSomethingThatUsesHealthChecker(t *testing.T) {
// make and configure a mocked service.HealthChecker
mockedHealthChecker := &HealthCheckerMock{
AddAndGetCheckFunc: func(name string, checker healthcheck.Checker) (*healthcheck.Check, error) {
panic("mock out the AddAndGetCheck method")
},
HandlerFunc: func(w http.ResponseWriter, req *http.Request) {
panic("mock out the Handler method")
},
StartFunc: func(ctx context.Context) {
panic("mock out the Start method")
},
StopFunc: func() {
panic("mock out the Stop method")
},
SubscribeFunc: func(s healthcheck.Subscriber, checks ...*healthcheck.Check) {
panic("mock out the Subscribe method")
},
}
// use mockedHealthChecker in code that requires service.HealthChecker
// and then make assertions.
}
func (*HealthCheckerMock) AddAndGetCheck ¶ added in v0.24.0
func (mock *HealthCheckerMock) AddAndGetCheck(name string, checker healthcheck.Checker) (*healthcheck.Check, error)
AddAndGetCheck calls AddAndGetCheckFunc.
func (*HealthCheckerMock) AddAndGetCheckCalls ¶ added in v0.24.0
func (mock *HealthCheckerMock) AddAndGetCheckCalls() []struct { Name string Checker healthcheck.Checker }
AddAndGetCheckCalls gets all the calls that were made to AddAndGetCheck. Check the length with:
len(mockedHealthChecker.AddAndGetCheckCalls())
func (*HealthCheckerMock) Handler ¶
func (mock *HealthCheckerMock) Handler(w http.ResponseWriter, req *http.Request)
Handler calls HandlerFunc.
func (*HealthCheckerMock) HandlerCalls ¶
func (mock *HealthCheckerMock) HandlerCalls() []struct { W http.ResponseWriter Req *http.Request }
HandlerCalls gets all the calls that were made to Handler. Check the length with:
len(mockedHealthChecker.HandlerCalls())
func (*HealthCheckerMock) Start ¶
func (mock *HealthCheckerMock) Start(ctx context.Context)
Start calls StartFunc.
func (*HealthCheckerMock) StartCalls ¶
func (mock *HealthCheckerMock) StartCalls() []struct { Ctx context.Context }
StartCalls gets all the calls that were made to Start. Check the length with:
len(mockedHealthChecker.StartCalls())
func (*HealthCheckerMock) StopCalls ¶
func (mock *HealthCheckerMock) StopCalls() []struct { }
StopCalls gets all the calls that were made to Stop. Check the length with:
len(mockedHealthChecker.StopCalls())
func (*HealthCheckerMock) Subscribe ¶ added in v0.24.0
func (mock *HealthCheckerMock) Subscribe(s healthcheck.Subscriber, checks ...*healthcheck.Check)
Subscribe calls SubscribeFunc.
func (*HealthCheckerMock) SubscribeCalls ¶ added in v0.24.0
func (mock *HealthCheckerMock) SubscribeCalls() []struct { S healthcheck.Subscriber Checks []*healthcheck.Check }
SubscribeCalls gets all the calls that were made to Subscribe. Check the length with:
len(mockedHealthChecker.SubscribeCalls())