mock

package
v1.31.0 Latest Latest
Warning

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

Go to latest
Published: Oct 23, 2026 License: MIT Imports: 12 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type OurProducerMock

type OurProducerMock struct {
	// AddHeaderFunc mocks the AddHeader method.
	AddHeaderFunc func(key string, value string)

	// ChannelsFunc mocks the Channels method.
	ChannelsFunc func() *kafka.ProducerChannels

	// 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

	// InitialiseFunc mocks the Initialise method.
	InitialiseFunc func(ctx context.Context) error

	// IsInitialisedFunc mocks the IsInitialised method.
	IsInitialisedFunc func() bool

	// LogErrorsFunc mocks the LogErrors method.
	LogErrorsFunc func(ctx context.Context)

	// SendFunc mocks the Send method.
	SendFunc func(schema *avro.Schema, event interface{}) error
	// contains filtered or unexported fields
}

OurProducerMock is a mock implementation of service.OurProducer.

func TestSomethingThatUsesOurProducer(t *testing.T) {

	// make and configure a mocked service.OurProducer
	mockedOurProducer := &OurProducerMock{
		AddHeaderFunc: func(key string, value string)  {
			panic("mock out the AddHeader method")
		},
		ChannelsFunc: func() *kafka.ProducerChannels {
			panic("mock out the Channels 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")
		},
		InitialiseFunc: func(ctx context.Context) error {
			panic("mock out the Initialise method")
		},
		IsInitialisedFunc: func() bool {
			panic("mock out the IsInitialised method")
		},
		LogErrorsFunc: func(ctx context.Context)  {
			panic("mock out the LogErrors method")
		},
		SendFunc: func(schema *avro.Schema, event interface{}) error {
			panic("mock out the Send method")
		},
	}

	// use mockedOurProducer in code that requires service.OurProducer
	// and then make assertions.

}

func (*OurProducerMock) AddHeader added in v1.3.0

func (mock *OurProducerMock) AddHeader(key string, value string)

AddHeader calls AddHeaderFunc.

func (*OurProducerMock) AddHeaderCalls added in v1.7.0

func (mock *OurProducerMock) AddHeaderCalls() []struct {
	Key   string
	Value string
}

AddHeaderCalls gets all the calls that were made to AddHeader. Check the length with:

len(mockedOurProducer.AddHeaderCalls())

func (*OurProducerMock) Channels

func (mock *OurProducerMock) Channels() *kafka.ProducerChannels

Channels calls ChannelsFunc.

func (*OurProducerMock) ChannelsCalls

func (mock *OurProducerMock) ChannelsCalls() []struct {
}

ChannelsCalls gets all the calls that were made to Channels. Check the length with:

len(mockedOurProducer.ChannelsCalls())

func (*OurProducerMock) Checker

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

Checker calls CheckerFunc.

func (*OurProducerMock) CheckerCalls

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

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

len(mockedOurProducer.CheckerCalls())

func (*OurProducerMock) Close

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

Close calls CloseFunc.

func (*OurProducerMock) CloseCalls

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

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

len(mockedOurProducer.CloseCalls())

func (*OurProducerMock) Initialise

func (mock *OurProducerMock) Initialise(ctx context.Context) error

Initialise calls InitialiseFunc.

func (*OurProducerMock) InitialiseCalls

func (mock *OurProducerMock) InitialiseCalls() []struct {
	Ctx context.Context
}

InitialiseCalls gets all the calls that were made to Initialise. Check the length with:

len(mockedOurProducer.InitialiseCalls())

func (*OurProducerMock) IsInitialised

func (mock *OurProducerMock) IsInitialised() bool

IsInitialised calls IsInitialisedFunc.

func (*OurProducerMock) IsInitialisedCalls

func (mock *OurProducerMock) IsInitialisedCalls() []struct {
}

IsInitialisedCalls gets all the calls that were made to IsInitialised. Check the length with:

len(mockedOurProducer.IsInitialisedCalls())

func (*OurProducerMock) LogErrors

func (mock *OurProducerMock) LogErrors(ctx context.Context)

LogErrors calls LogErrorsFunc.

func (*OurProducerMock) LogErrorsCalls

func (mock *OurProducerMock) LogErrorsCalls() []struct {
	Ctx context.Context
}

LogErrorsCalls gets all the calls that were made to LogErrors. Check the length with:

len(mockedOurProducer.LogErrorsCalls())

func (*OurProducerMock) Send

func (mock *OurProducerMock) Send(schema *avro.Schema, event interface{}) error

Send calls SendFunc.

func (*OurProducerMock) SendCalls

func (mock *OurProducerMock) SendCalls() []struct {
	Schema *avro.Schema
	Event  interface{}
}

SendCalls gets all the calls that were made to Send. Check the length with:

len(mockedOurProducer.SendCalls())

type ServiceContainerMock

type ServiceContainerMock struct {
	// GetAuthMiddlewareFunc mocks the GetAuthMiddleware method.
	GetAuthMiddlewareFunc func() auth.Middleware

	// GetClockFunc mocks the GetClock method.
	GetClockFunc func() clock.Clock

	// GetHTTPServerFunc mocks the GetHTTPServer method.
	GetHTTPServerFunc func() files.HTTPServer

	// GetHealthCheckFunc mocks the GetHealthCheck method.
	GetHealthCheckFunc func() health.Checker

	// GetKafkaProducerFunc mocks the GetKafkaProducer method.
	GetKafkaProducerFunc func() kafka.IProducer

	// GetMongoDBFunc mocks the GetMongoDB method.
	GetMongoDBFunc func() mongo.Client

	// GetS3ClienterFunc mocks the GetS3Clienter method.
	GetS3ClienterFunc func() aws.S3Clienter

	// ShutdownFunc mocks the Shutdown method.
	ShutdownFunc func(ctx context.Context) error
	// contains filtered or unexported fields
}

ServiceContainerMock is a mock implementation of service.ServiceContainer.

func TestSomethingThatUsesServiceContainer(t *testing.T) {

	// make and configure a mocked service.ServiceContainer
	mockedServiceContainer := &ServiceContainerMock{
		GetAuthMiddlewareFunc: func() auth.Middleware {
			panic("mock out the GetAuthMiddleware method")
		},
		GetClockFunc: func() clock.Clock {
			panic("mock out the GetClock method")
		},
		GetHTTPServerFunc: func() files.HTTPServer {
			panic("mock out the GetHTTPServer method")
		},
		GetHealthCheckFunc: func() health.Checker {
			panic("mock out the GetHealthCheck method")
		},
		GetKafkaProducerFunc: func() kafka.IProducer {
			panic("mock out the GetKafkaProducer method")
		},
		GetMongoDBFunc: func() mongo.Client {
			panic("mock out the GetMongoDB method")
		},
		GetS3ClienterFunc: func() aws.S3Clienter {
			panic("mock out the GetS3Clienter method")
		},
		ShutdownFunc: func(ctx context.Context) error {
			panic("mock out the Shutdown method")
		},
	}

	// use mockedServiceContainer in code that requires service.ServiceContainer
	// and then make assertions.

}

func (*ServiceContainerMock) GetAuthMiddleware

func (mock *ServiceContainerMock) GetAuthMiddleware() auth.Middleware

GetAuthMiddleware calls GetAuthMiddlewareFunc.

func (*ServiceContainerMock) GetAuthMiddlewareCalls

func (mock *ServiceContainerMock) GetAuthMiddlewareCalls() []struct {
}

GetAuthMiddlewareCalls gets all the calls that were made to GetAuthMiddleware. Check the length with:

len(mockedServiceContainer.GetAuthMiddlewareCalls())

func (*ServiceContainerMock) GetClock

func (mock *ServiceContainerMock) GetClock() clock.Clock

GetClock calls GetClockFunc.

func (*ServiceContainerMock) GetClockCalls

func (mock *ServiceContainerMock) GetClockCalls() []struct {
}

GetClockCalls gets all the calls that were made to GetClock. Check the length with:

len(mockedServiceContainer.GetClockCalls())

func (*ServiceContainerMock) GetHTTPServer

func (mock *ServiceContainerMock) GetHTTPServer() files.HTTPServer

GetHTTPServer calls GetHTTPServerFunc.

func (*ServiceContainerMock) GetHTTPServerCalls

func (mock *ServiceContainerMock) GetHTTPServerCalls() []struct {
}

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

len(mockedServiceContainer.GetHTTPServerCalls())

func (*ServiceContainerMock) GetHealthCheck

func (mock *ServiceContainerMock) GetHealthCheck() health.Checker

GetHealthCheck calls GetHealthCheckFunc.

func (*ServiceContainerMock) GetHealthCheckCalls

func (mock *ServiceContainerMock) GetHealthCheckCalls() []struct {
}

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

len(mockedServiceContainer.GetHealthCheckCalls())

func (*ServiceContainerMock) GetKafkaProducer

func (mock *ServiceContainerMock) GetKafkaProducer() kafka.IProducer

GetKafkaProducer calls GetKafkaProducerFunc.

func (*ServiceContainerMock) GetKafkaProducerCalls

func (mock *ServiceContainerMock) GetKafkaProducerCalls() []struct {
}

GetKafkaProducerCalls gets all the calls that were made to GetKafkaProducer. Check the length with:

len(mockedServiceContainer.GetKafkaProducerCalls())

func (*ServiceContainerMock) GetMongoDB

func (mock *ServiceContainerMock) GetMongoDB() mongo.Client

GetMongoDB calls GetMongoDBFunc.

func (*ServiceContainerMock) GetMongoDBCalls

func (mock *ServiceContainerMock) GetMongoDBCalls() []struct {
}

GetMongoDBCalls gets all the calls that were made to GetMongoDB. Check the length with:

len(mockedServiceContainer.GetMongoDBCalls())

func (*ServiceContainerMock) GetPermissionsChecker added in v1.22.0

func (mock *ServiceContainerMock) GetPermissionsChecker() auth.PermissionsChecker

GetPermissionsChecker returns nil unless regenerated with moq including this method.

func (*ServiceContainerMock) GetS3Clienter added in v1.3.0

func (mock *ServiceContainerMock) GetS3Clienter() aws.S3Clienter

GetS3Clienter calls GetS3ClienterFunc.

func (*ServiceContainerMock) GetS3ClienterCalls added in v1.3.0

func (mock *ServiceContainerMock) GetS3ClienterCalls() []struct {
}

GetS3ClienterCalls gets all the calls that were made to GetS3Clienter. Check the length with:

len(mockedServiceContainer.GetS3ClienterCalls())

func (*ServiceContainerMock) GetZebedeeClient added in v1.22.0

func (mock *ServiceContainerMock) GetZebedeeClient() auth.ZebedeeClient

GetZebedeeClient returns nil unless regenerated with moq including this method.

func (*ServiceContainerMock) Shutdown

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

Shutdown calls ShutdownFunc.

func (*ServiceContainerMock) ShutdownCalls

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

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

len(mockedServiceContainer.ShutdownCalls())

Jump to

Keyboard shortcuts

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