mock

package
v0.10.1 Latest Latest
Warning

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

Go to latest
Published: Jun 15, 2023 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CloserMock added in v0.5.0

type CloserMock struct {
	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context) error
	// contains filtered or unexported fields
}

CloserMock is a mock implementation of service.Closer.

func TestSomethingThatUsesCloser(t *testing.T) {

	// make and configure a mocked service.Closer
	mockedCloser := &CloserMock{
		CloseFunc: func(ctx context.Context) error {
			panic("mock out the Close method")
		},
	}

	// use mockedCloser in code that requires service.Closer
	// and then make assertions.

}

func (*CloserMock) Close added in v0.5.0

func (mock *CloserMock) Close(ctx context.Context) error

Close calls CloseFunc.

func (*CloserMock) CloseCalls added in v0.5.0

func (mock *CloserMock) CloseCalls() []struct {
	Ctx context.Context
}

CloseCalls gets all the calls that were made to Close. Check the length with:

len(mockedCloser.CloseCalls())

type IHealthCheckMock

type IHealthCheckMock 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
}

IHealthCheckMock is a mock implementation of service.IHealthCheck.

func TestSomethingThatUsesIHealthCheck(t *testing.T) {

	// make and configure a mocked service.IHealthCheck
	mockedIHealthCheck := &IHealthCheckMock{
		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 mockedIHealthCheck in code that requires service.IHealthCheck
	// and then make assertions.

}

func (*IHealthCheckMock) AddCheck

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

AddCheck calls AddCheckFunc.

func (*IHealthCheckMock) AddCheckCalls

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

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

len(mockedIHealthCheck.AddCheckCalls())

func (*IHealthCheckMock) Handler

func (mock *IHealthCheckMock) Handler(w http.ResponseWriter, req *http.Request)

Handler calls HandlerFunc.

func (*IHealthCheckMock) HandlerCalls

func (mock *IHealthCheckMock) HandlerCalls() []struct {
	W   http.ResponseWriter
	Req *http.Request
}

HandlerCalls gets all the calls that were made to Handler. Check the length with:

len(mockedIHealthCheck.HandlerCalls())

func (*IHealthCheckMock) Start

func (mock *IHealthCheckMock) Start(ctx context.Context)

Start calls StartFunc.

func (*IHealthCheckMock) StartCalls

func (mock *IHealthCheckMock) StartCalls() []struct {
	Ctx context.Context
}

StartCalls gets all the calls that were made to Start. Check the length with:

len(mockedIHealthCheck.StartCalls())

func (*IHealthCheckMock) Stop

func (mock *IHealthCheckMock) Stop()

Stop calls StopFunc.

func (*IHealthCheckMock) StopCalls

func (mock *IHealthCheckMock) StopCalls() []struct {
}

StopCalls gets all the calls that were made to Stop. Check the length with:

len(mockedIHealthCheck.StopCalls())

type IServerMock

type IServerMock 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
}

IServerMock is a mock implementation of service.IServer.

func TestSomethingThatUsesIServer(t *testing.T) {

	// make and configure a mocked service.IServer
	mockedIServer := &IServerMock{
		ListenAndServeFunc: func() error {
			panic("mock out the ListenAndServe method")
		},
		ShutdownFunc: func(ctx context.Context) error {
			panic("mock out the Shutdown method")
		},
	}

	// use mockedIServer in code that requires service.IServer
	// and then make assertions.

}

func (*IServerMock) ListenAndServe

func (mock *IServerMock) ListenAndServe() error

ListenAndServe calls ListenAndServeFunc.

func (*IServerMock) ListenAndServeCalls

func (mock *IServerMock) ListenAndServeCalls() []struct {
}

ListenAndServeCalls gets all the calls that were made to ListenAndServe. Check the length with:

len(mockedIServer.ListenAndServeCalls())

func (*IServerMock) Shutdown

func (mock *IServerMock) Shutdown(ctx context.Context) error

Shutdown calls ShutdownFunc.

func (*IServerMock) ShutdownCalls

func (mock *IServerMock) ShutdownCalls() []struct {
	Ctx context.Context
}

ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:

len(mockedIServer.ShutdownCalls())

type InitialiserMock

type InitialiserMock struct {
	// DoGetGraphDBFunc mocks the DoGetGraphDB method.
	DoGetGraphDBFunc func(ctx context.Context) (api.IGraph, service.Closer, error)

	// DoGetHTTPServerFunc mocks the DoGetHTTPServer method.
	DoGetHTTPServerFunc func(bindAddr string, httpWriteTimeout time.Duration, router http.Handler) service.IServer

	// DoGetHealthCheckFunc mocks the DoGetHealthCheck method.
	DoGetHealthCheckFunc func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.IHealthCheck, error)
	// 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{
		DoGetGraphDBFunc: func(ctx context.Context) (api.IGraph, service.Closer, error) {
			panic("mock out the DoGetGraphDB method")
		},
		DoGetHTTPServerFunc: func(bindAddr string, httpWriteTimeout time.Duration, router http.Handler) service.IServer {
			panic("mock out the DoGetHTTPServer method")
		},
		DoGetHealthCheckFunc: func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.IHealthCheck, error) {
			panic("mock out the DoGetHealthCheck method")
		},
	}

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

}

func (*InitialiserMock) DoGetGraphDB

func (mock *InitialiserMock) DoGetGraphDB(ctx context.Context) (api.IGraph, service.Closer, error)

DoGetGraphDB calls DoGetGraphDBFunc.

func (*InitialiserMock) DoGetGraphDBCalls

func (mock *InitialiserMock) DoGetGraphDBCalls() []struct {
	Ctx context.Context
}

DoGetGraphDBCalls gets all the calls that were made to DoGetGraphDB. Check the length with:

len(mockedInitialiser.DoGetGraphDBCalls())

func (*InitialiserMock) DoGetHTTPServer

func (mock *InitialiserMock) DoGetHTTPServer(bindAddr string, httpWriteTimeout time.Duration, router http.Handler) service.IServer

DoGetHTTPServer calls DoGetHTTPServerFunc.

func (*InitialiserMock) DoGetHTTPServerCalls

func (mock *InitialiserMock) DoGetHTTPServerCalls() []struct {
	BindAddr         string
	HttpWriteTimeout time.Duration
	Router           http.Handler
}

DoGetHTTPServerCalls gets all the calls that were made to DoGetHTTPServer. Check the length with:

len(mockedInitialiser.DoGetHTTPServerCalls())

func (*InitialiserMock) DoGetHealthCheck

func (mock *InitialiserMock) DoGetHealthCheck(cfg *config.Config, buildTime string, gitCommit string, version string) (service.IHealthCheck, error)

DoGetHealthCheck calls DoGetHealthCheckFunc.

func (*InitialiserMock) DoGetHealthCheckCalls

func (mock *InitialiserMock) DoGetHealthCheckCalls() []struct {
	Cfg       *config.Config
	BuildTime string
	GitCommit string
	Version   string
}

DoGetHealthCheckCalls gets all the calls that were made to DoGetHealthCheck. Check the length with:

len(mockedInitialiser.DoGetHealthCheckCalls())

Jump to

Keyboard shortcuts

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