mock

package
v0.27.0 Latest Latest
Warning

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

Go to latest
Published: May 18, 2023 License: MIT Imports: 11 Imported by: 0

Documentation

Index

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 {
	// 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 {
	// DoGetAuthorisationHandlersFunc mocks the DoGetAuthorisationHandlers method.
	DoGetAuthorisationHandlersFunc func(ctx context.Context, cfg *config.Config) api.AuthHandler

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

	// DoGetHealthCheckFunc mocks the DoGetHealthCheck method.
	DoGetHealthCheckFunc func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error)

	// DoGetHealthClientFunc mocks the DoGetHealthClient method.
	DoGetHealthClientFunc func(name string, url string) *health.Client

	// DoGetKafkaProducerFunc mocks the DoGetKafkaProducer method.
	DoGetKafkaProducerFunc func(ctx context.Context, cfg *config.Config) (service.KafkaProducer, error)

	// DoGetMongoDBFunc mocks the DoGetMongoDB method.
	DoGetMongoDBFunc func(ctx context.Context, mgoCfg config.MongoConfig) (service.MongoDataStorer, 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{
		DoGetAuthorisationHandlersFunc: func(ctx context.Context, cfg *config.Config) api.AuthHandler {
			panic("mock out the DoGetAuthorisationHandlers method")
		},
		DoGetHTTPServerFunc: func(bindAddr string, router http.Handler) service.HTTPServer {
			panic("mock out the DoGetHTTPServer method")
		},
		DoGetHealthCheckFunc: func(cfg *config.Config, buildTime string, gitCommit string, version string) (service.HealthChecker, error) {
			panic("mock out the DoGetHealthCheck method")
		},
		DoGetHealthClientFunc: func(name string, url string) *health.Client {
			panic("mock out the DoGetHealthClient method")
		},
		DoGetKafkaProducerFunc: func(ctx context.Context, cfg *config.Config) (service.KafkaProducer, error) {
			panic("mock out the DoGetKafkaProducer method")
		},
		DoGetMongoDBFunc: func(ctx context.Context, mgoCfg config.MongoConfig) (service.MongoDataStorer, error) {
			panic("mock out the DoGetMongoDB method")
		},
	}

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

}

func (*InitialiserMock) DoGetAuthorisationHandlers added in v0.9.0

func (mock *InitialiserMock) DoGetAuthorisationHandlers(ctx context.Context, cfg *config.Config) api.AuthHandler

DoGetAuthorisationHandlers calls DoGetAuthorisationHandlersFunc.

func (*InitialiserMock) DoGetAuthorisationHandlersCalls added in v0.9.0

func (mock *InitialiserMock) DoGetAuthorisationHandlersCalls() []struct {
	Ctx context.Context
	Cfg *config.Config
}

DoGetAuthorisationHandlersCalls gets all the calls that were made to DoGetAuthorisationHandlers. Check the length with:

len(mockedInitialiser.DoGetAuthorisationHandlersCalls())

func (*InitialiserMock) DoGetHTTPServer

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

DoGetHTTPServer calls DoGetHTTPServerFunc.

func (*InitialiserMock) DoGetHTTPServerCalls

func (mock *InitialiserMock) DoGetHTTPServerCalls() []struct {
	BindAddr string
	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.HealthChecker, 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())

func (*InitialiserMock) DoGetHealthClient added in v0.5.0

func (mock *InitialiserMock) DoGetHealthClient(name string, url string) *health.Client

DoGetHealthClient calls DoGetHealthClientFunc.

func (*InitialiserMock) DoGetHealthClientCalls added in v0.5.0

func (mock *InitialiserMock) DoGetHealthClientCalls() []struct {
	Name string
	URL  string
}

DoGetHealthClientCalls gets all the calls that were made to DoGetHealthClient. Check the length with:

len(mockedInitialiser.DoGetHealthClientCalls())

func (*InitialiserMock) DoGetKafkaProducer added in v0.15.0

func (mock *InitialiserMock) DoGetKafkaProducer(ctx context.Context, cfg *config.Config) (service.KafkaProducer, error)

DoGetKafkaProducer calls DoGetKafkaProducerFunc.

func (*InitialiserMock) DoGetKafkaProducerCalls added in v0.15.0

func (mock *InitialiserMock) DoGetKafkaProducerCalls() []struct {
	Ctx context.Context
	Cfg *config.Config
}

DoGetKafkaProducerCalls gets all the calls that were made to DoGetKafkaProducer. Check the length with:

len(mockedInitialiser.DoGetKafkaProducerCalls())

func (*InitialiserMock) DoGetMongoDB added in v0.5.0

func (mock *InitialiserMock) DoGetMongoDB(ctx context.Context, mgoCfg config.MongoConfig) (service.MongoDataStorer, error)

DoGetMongoDB calls DoGetMongoDBFunc.

func (*InitialiserMock) DoGetMongoDBCalls added in v0.5.0

func (mock *InitialiserMock) DoGetMongoDBCalls() []struct {
	Ctx    context.Context
	MgoCfg config.MongoConfig
}

DoGetMongoDBCalls gets all the calls that were made to DoGetMongoDB. Check the length with:

len(mockedInitialiser.DoGetMongoDBCalls())

type KafkaProducerMock added in v0.15.0

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

	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context) error

	// ProduceReindexRequestedFunc mocks the ProduceReindexRequested method.
	ProduceReindexRequestedFunc func(ctx context.Context, event models.ReindexRequested) error
	// contains filtered or unexported fields
}

KafkaProducerMock is a mock implementation of service.KafkaProducer.

    func TestSomethingThatUsesKafkaProducer(t *testing.T) {

        // make and configure a mocked service.KafkaProducer
        mockedKafkaProducer := &KafkaProducerMock{
            CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
	               panic("mock out the Checker method")
            },
            CloseFunc: func(ctx context.Context) error {
	               panic("mock out the Close method")
            },
            ProduceReindexRequestedFunc: func(ctx context.Context, event models.ReindexRequested) error {
	               panic("mock out the ProduceReindexRequested method")
            },
        }

        // use mockedKafkaProducer in code that requires service.KafkaProducer
        // and then make assertions.

    }

func (*KafkaProducerMock) Checker added in v0.15.0

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

Checker calls CheckerFunc.

func (*KafkaProducerMock) CheckerCalls added in v0.15.0

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

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

len(mockedKafkaProducer.CheckerCalls())

func (*KafkaProducerMock) Close added in v0.15.0

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

Close calls CloseFunc.

func (*KafkaProducerMock) CloseCalls added in v0.15.0

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

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

len(mockedKafkaProducer.CloseCalls())

func (*KafkaProducerMock) ProduceReindexRequested added in v0.15.0

func (mock *KafkaProducerMock) ProduceReindexRequested(ctx context.Context, event models.ReindexRequested) error

ProduceReindexRequested calls ProduceReindexRequestedFunc.

func (*KafkaProducerMock) ProduceReindexRequestedCalls added in v0.15.0

func (mock *KafkaProducerMock) ProduceReindexRequestedCalls() []struct {
	Ctx   context.Context
	Event models.ReindexRequested
}

ProduceReindexRequestedCalls gets all the calls that were made to ProduceReindexRequested. Check the length with:

len(mockedKafkaProducer.ProduceReindexRequestedCalls())

type MongoDataStorerMock added in v0.12.0

type MongoDataStorerMock struct {
	// AcquireJobLockFunc mocks the AcquireJobLock method.
	AcquireJobLockFunc func(ctx context.Context, id string) (string, error)

	// CheckInProgressJobFunc mocks the CheckInProgressJob method.
	CheckInProgressJobFunc func(ctx context.Context, cfg *config.Config) error

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

	// CloseFunc mocks the Close method.
	CloseFunc func(ctx context.Context) error

	// CreateJobFunc mocks the CreateJob method.
	CreateJobFunc func(ctx context.Context, job models.Job) error

	// GetJobFunc mocks the GetJob method.
	GetJobFunc func(ctx context.Context, id string) (*models.Job, error)

	// GetJobsFunc mocks the GetJobs method.
	GetJobsFunc func(ctx context.Context, options mongo.Options) (*models.Jobs, error)

	// GetTaskFunc mocks the GetTask method.
	GetTaskFunc func(ctx context.Context, jobID string, taskName string) (*models.Task, error)

	// GetTasksFunc mocks the GetTasks method.
	GetTasksFunc func(ctx context.Context, jobID string, options mongo.Options) (*models.Tasks, error)

	// UnlockJobFunc mocks the UnlockJob method.
	UnlockJobFunc func(ctx context.Context, lockID string)

	// UpdateJobFunc mocks the UpdateJob method.
	UpdateJobFunc func(ctx context.Context, id string, updates primitive.M) error

	// UpsertTaskFunc mocks the UpsertTask method.
	UpsertTaskFunc func(ctx context.Context, jobID string, taskName string, task models.Task) error
	// contains filtered or unexported fields
}

MongoDataStorerMock is a mock implementation of service.MongoDataStorer.

func TestSomethingThatUsesMongoDataStorer(t *testing.T) {

	// make and configure a mocked service.MongoDataStorer
	mockedMongoDataStorer := &MongoDataStorerMock{
		AcquireJobLockFunc: func(ctx context.Context, id string) (string, error) {
			panic("mock out the AcquireJobLock method")
		},
		CheckInProgressJobFunc: func(ctx context.Context, cfg *config.Config) error {
			panic("mock out the CheckInProgressJob method")
		},
		CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		CloseFunc: func(ctx context.Context) error {
			panic("mock out the Close method")
		},
		CreateJobFunc: func(ctx context.Context, job models.Job) error {
			panic("mock out the CreateJob method")
		},
		GetJobFunc: func(ctx context.Context, id string) (*models.Job, error) {
			panic("mock out the GetJob method")
		},
		GetJobsFunc: func(ctx context.Context, options mongo.Options) (*models.Jobs, error) {
			panic("mock out the GetJobs method")
		},
		GetTaskFunc: func(ctx context.Context, jobID string, taskName string) (*models.Task, error) {
			panic("mock out the GetTask method")
		},
		GetTasksFunc: func(ctx context.Context, jobID string, options mongo.Options) (*models.Tasks, error) {
			panic("mock out the GetTasks method")
		},
		UnlockJobFunc: func(ctx context.Context, lockID string)  {
			panic("mock out the UnlockJob method")
		},
		UpdateJobFunc: func(ctx context.Context, id string, updates primitive.M) error {
			panic("mock out the UpdateJob method")
		},
		UpsertTaskFunc: func(ctx context.Context, jobID string, taskName string, task models.Task) error {
			panic("mock out the UpsertTask method")
		},
	}

	// use mockedMongoDataStorer in code that requires service.MongoDataStorer
	// and then make assertions.

}

func (*MongoDataStorerMock) AcquireJobLock added in v0.12.0

func (mock *MongoDataStorerMock) AcquireJobLock(ctx context.Context, id string) (string, error)

AcquireJobLock calls AcquireJobLockFunc.

func (*MongoDataStorerMock) AcquireJobLockCalls added in v0.12.0

func (mock *MongoDataStorerMock) AcquireJobLockCalls() []struct {
	Ctx context.Context
	ID  string
}

AcquireJobLockCalls gets all the calls that were made to AcquireJobLock. Check the length with:

len(mockedMongoDataStorer.AcquireJobLockCalls())

func (*MongoDataStorerMock) CheckInProgressJob added in v0.21.0

func (mock *MongoDataStorerMock) CheckInProgressJob(ctx context.Context, cfg *config.Config) error

CheckInProgressJob calls CheckInProgressJobFunc.

func (*MongoDataStorerMock) CheckInProgressJobCalls added in v0.21.0

func (mock *MongoDataStorerMock) CheckInProgressJobCalls() []struct {
	Ctx context.Context
	Cfg *config.Config
}

CheckInProgressJobCalls gets all the calls that were made to CheckInProgressJob. Check the length with:

len(mockedMongoDataStorer.CheckInProgressJobCalls())

func (*MongoDataStorerMock) Checker added in v0.12.0

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

Checker calls CheckerFunc.

func (*MongoDataStorerMock) CheckerCalls added in v0.12.0

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

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

len(mockedMongoDataStorer.CheckerCalls())

func (*MongoDataStorerMock) Close added in v0.12.0

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

Close calls CloseFunc.

func (*MongoDataStorerMock) CloseCalls added in v0.12.0

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

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

len(mockedMongoDataStorer.CloseCalls())

func (*MongoDataStorerMock) CreateJob added in v0.12.0

func (mock *MongoDataStorerMock) CreateJob(ctx context.Context, job models.Job) error

CreateJob calls CreateJobFunc.

func (*MongoDataStorerMock) CreateJobCalls added in v0.12.0

func (mock *MongoDataStorerMock) CreateJobCalls() []struct {
	Ctx context.Context
	Job models.Job
}

CreateJobCalls gets all the calls that were made to CreateJob. Check the length with:

len(mockedMongoDataStorer.CreateJobCalls())

func (*MongoDataStorerMock) GetJob added in v0.12.0

func (mock *MongoDataStorerMock) GetJob(ctx context.Context, id string) (*models.Job, error)

GetJob calls GetJobFunc.

func (*MongoDataStorerMock) GetJobCalls added in v0.12.0

func (mock *MongoDataStorerMock) GetJobCalls() []struct {
	Ctx context.Context
	ID  string
}

GetJobCalls gets all the calls that were made to GetJob. Check the length with:

len(mockedMongoDataStorer.GetJobCalls())

func (*MongoDataStorerMock) GetJobs added in v0.12.0

func (mock *MongoDataStorerMock) GetJobs(ctx context.Context, options mongo.Options) (*models.Jobs, error)

GetJobs calls GetJobsFunc.

func (*MongoDataStorerMock) GetJobsCalls added in v0.12.0

func (mock *MongoDataStorerMock) GetJobsCalls() []struct {
	Ctx     context.Context
	Options mongo.Options
}

GetJobsCalls gets all the calls that were made to GetJobs. Check the length with:

len(mockedMongoDataStorer.GetJobsCalls())

func (*MongoDataStorerMock) GetTask added in v0.12.0

func (mock *MongoDataStorerMock) GetTask(ctx context.Context, jobID string, taskName string) (*models.Task, error)

GetTask calls GetTaskFunc.

func (*MongoDataStorerMock) GetTaskCalls added in v0.12.0

func (mock *MongoDataStorerMock) GetTaskCalls() []struct {
	Ctx      context.Context
	JobID    string
	TaskName string
}

GetTaskCalls gets all the calls that were made to GetTask. Check the length with:

len(mockedMongoDataStorer.GetTaskCalls())

func (*MongoDataStorerMock) GetTasks added in v0.12.0

func (mock *MongoDataStorerMock) GetTasks(ctx context.Context, jobID string, options mongo.Options) (*models.Tasks, error)

GetTasks calls GetTasksFunc.

func (*MongoDataStorerMock) GetTasksCalls added in v0.12.0

func (mock *MongoDataStorerMock) GetTasksCalls() []struct {
	Ctx     context.Context
	JobID   string
	Options mongo.Options
}

GetTasksCalls gets all the calls that were made to GetTasks. Check the length with:

len(mockedMongoDataStorer.GetTasksCalls())

func (*MongoDataStorerMock) UnlockJob added in v0.12.0

func (mock *MongoDataStorerMock) UnlockJob(ctx context.Context, lockID string)

UnlockJob calls UnlockJobFunc.

func (*MongoDataStorerMock) UnlockJobCalls added in v0.12.0

func (mock *MongoDataStorerMock) UnlockJobCalls() []struct {
	Ctx    context.Context
	LockID string
}

UnlockJobCalls gets all the calls that were made to UnlockJob. Check the length with:

len(mockedMongoDataStorer.UnlockJobCalls())

func (*MongoDataStorerMock) UpdateJob added in v0.21.0

func (mock *MongoDataStorerMock) UpdateJob(ctx context.Context, id string, updates primitive.M) error

UpdateJob calls UpdateJobFunc.

func (*MongoDataStorerMock) UpdateJobCalls added in v0.21.0

func (mock *MongoDataStorerMock) UpdateJobCalls() []struct {
	Ctx     context.Context
	ID      string
	Updates primitive.M
}

UpdateJobCalls gets all the calls that were made to UpdateJob. Check the length with:

len(mockedMongoDataStorer.UpdateJobCalls())

func (*MongoDataStorerMock) UpsertTask added in v0.21.0

func (mock *MongoDataStorerMock) UpsertTask(ctx context.Context, jobID string, taskName string, task models.Task) error

UpsertTask calls UpsertTaskFunc.

func (*MongoDataStorerMock) UpsertTaskCalls added in v0.21.0

func (mock *MongoDataStorerMock) UpsertTaskCalls() []struct {
	Ctx      context.Context
	JobID    string
	TaskName string
	Task     models.Task
}

UpsertTaskCalls gets all the calls that were made to UpsertTask. Check the length with:

len(mockedMongoDataStorer.UpsertTaskCalls())

Jump to

Keyboard shortcuts

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