mock

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Apr 27, 2022 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CantabularClientMock added in v1.1.0

type CantabularClientMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, state *healthcheck.CheckState) error

	// ListDatasetsFunc mocks the ListDatasets method.
	ListDatasetsFunc func(ctx context.Context) ([]string, error)
	// contains filtered or unexported fields
}

CantabularClientMock is a mock implementation of service.CantabularClient.

func TestSomethingThatUsesCantabularClient(t *testing.T) {

	// make and configure a mocked service.CantabularClient
	mockedCantabularClient := &CantabularClientMock{
		CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		ListDatasetsFunc: func(ctx context.Context) ([]string, error) {
			panic("mock out the ListDatasets method")
		},
	}

	// use mockedCantabularClient in code that requires service.CantabularClient
	// and then make assertions.

}

func (*CantabularClientMock) Checker added in v1.1.0

func (mock *CantabularClientMock) Checker(ctx context.Context, state *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*CantabularClientMock) CheckerCalls added in v1.1.0

func (mock *CantabularClientMock) CheckerCalls() []struct {
	Ctx   context.Context
	State *healthcheck.CheckState
}

CheckerCalls gets all the calls that were made to Checker. Check the length with:

len(mockedCantabularClient.CheckerCalls())

func (*CantabularClientMock) ListDatasets added in v1.1.0

func (mock *CantabularClientMock) ListDatasets(ctx context.Context) ([]string, error)

ListDatasets calls ListDatasetsFunc.

func (*CantabularClientMock) ListDatasetsCalls added in v1.1.0

func (mock *CantabularClientMock) ListDatasetsCalls() []struct {
	Ctx context.Context
}

ListDatasetsCalls gets all the calls that were made to ListDatasets. Check the length with:

len(mockedCantabularClient.ListDatasetsCalls())

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 {
	// AddCheckFunc mocks the AddCheck method.
	AddCheckFunc func(name string, checker healthcheck.Checker) 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()
	// 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{
		AddCheckFunc: func(name string, checker healthcheck.Checker) error {
			panic("mock out the AddCheck 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")
		},
	}

	// use mockedHealthChecker in code that requires service.HealthChecker
	// and then make assertions.

}

func (*HealthCheckerMock) AddCheck

func (mock *HealthCheckerMock) AddCheck(name string, checker healthcheck.Checker) error

AddCheck calls AddCheckFunc.

func (*HealthCheckerMock) AddCheckCalls

func (mock *HealthCheckerMock) AddCheckCalls() []struct {
	Name    string
	Checker healthcheck.Checker
}

AddCheckCalls gets all the calls that were made to AddCheck. Check the length with:

len(mockedHealthChecker.AddCheckCalls())

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) Stop

func (mock *HealthCheckerMock) Stop()

Stop calls StopFunc.

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())

type InitialiserMock

type InitialiserMock struct {
	// GetCantabularClientFunc mocks the GetCantabularClient method.
	GetCantabularClientFunc func(cfg config.CantabularConfig) service.CantabularClient

	// GetHTTPServerFunc mocks the GetHTTPServer method.
	GetHTTPServerFunc func(bindAddr string, router http.Handler) service.HTTPServer

	// GetHealthCheckFunc mocks the GetHealthCheck method.
	GetHealthCheckFunc func(cfg *config.Config, time string, commit string, version string) (service.HealthChecker, error)

	// GetResponderFunc mocks the GetResponder method.
	GetResponderFunc func() service.Responder
	// contains filtered or unexported fields
}

InitialiserMock is a mock implementation of service.Initialiser.

func TestSomethingThatUsesInitialiser(t *testing.T) {

	// make and configure a mocked service.Initialiser
	mockedInitialiser := &InitialiserMock{
		GetCantabularClientFunc: func(cfg config.CantabularConfig) service.CantabularClient {
			panic("mock out the GetCantabularClient method")
		},
		GetHTTPServerFunc: func(bindAddr string, router http.Handler) service.HTTPServer {
			panic("mock out the GetHTTPServer method")
		},
		GetHealthCheckFunc: func(cfg *config.Config, time string, commit string, version string) (service.HealthChecker, error) {
			panic("mock out the GetHealthCheck method")
		},
		GetResponderFunc: func() service.Responder {
			panic("mock out the GetResponder method")
		},
	}

	// use mockedInitialiser in code that requires service.Initialiser
	// and then make assertions.

}

func (*InitialiserMock) GetCantabularClient added in v1.1.0

func (mock *InitialiserMock) GetCantabularClient(cfg config.CantabularConfig) service.CantabularClient

GetCantabularClient calls GetCantabularClientFunc.

func (*InitialiserMock) GetCantabularClientCalls added in v1.1.0

func (mock *InitialiserMock) GetCantabularClientCalls() []struct {
	Cfg config.CantabularConfig
}

GetCantabularClientCalls gets all the calls that were made to GetCantabularClient. Check the length with:

len(mockedInitialiser.GetCantabularClientCalls())

func (*InitialiserMock) GetHTTPServer added in v1.1.0

func (mock *InitialiserMock) GetHTTPServer(bindAddr string, router http.Handler) service.HTTPServer

GetHTTPServer calls GetHTTPServerFunc.

func (*InitialiserMock) GetHTTPServerCalls added in v1.1.0

func (mock *InitialiserMock) GetHTTPServerCalls() []struct {
	BindAddr string
	Router   http.Handler
}

GetHTTPServerCalls gets all the calls that were made to GetHTTPServer. Check the length with:

len(mockedInitialiser.GetHTTPServerCalls())

func (*InitialiserMock) GetHealthCheck added in v1.1.0

func (mock *InitialiserMock) GetHealthCheck(cfg *config.Config, time string, commit string, version string) (service.HealthChecker, error)

GetHealthCheck calls GetHealthCheckFunc.

func (*InitialiserMock) GetHealthCheckCalls added in v1.1.0

func (mock *InitialiserMock) GetHealthCheckCalls() []struct {
	Cfg     *config.Config
	Time    string
	Commit  string
	Version string
}

GetHealthCheckCalls gets all the calls that were made to GetHealthCheck. Check the length with:

len(mockedInitialiser.GetHealthCheckCalls())

func (*InitialiserMock) GetResponder added in v1.1.0

func (mock *InitialiserMock) GetResponder() service.Responder

GetResponder calls GetResponderFunc.

func (*InitialiserMock) GetResponderCalls added in v1.1.0

func (mock *InitialiserMock) GetResponderCalls() []struct {
}

GetResponderCalls gets all the calls that were made to GetResponder. Check the length with:

len(mockedInitialiser.GetResponderCalls())

Jump to

Keyboard shortcuts

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