mock

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Mar 18, 2024 License: MIT Imports: 9 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 {
	// 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)

	// DoGetImageAPIFunc mocks the DoGetImageAPI method.
	DoGetImageAPIFunc func(ctx context.Context, cfg *config.Config) event.ImageAPIClient

	// DoGetKafkaConsumerFunc mocks the DoGetKafkaConsumer method.
	DoGetKafkaConsumerFunc func(ctx context.Context, cfg *config.Config) (kafka.IConsumerGroup, error)

	// DoGetS3ClientFunc mocks the DoGetS3Client method.
	DoGetS3ClientFunc func(awsRegion string, bucketName string) (event.S3Writer, error)

	// DoGetS3ClientWithSessionFunc mocks the DoGetS3ClientWithSession method.
	DoGetS3ClientWithSessionFunc func(bucketName string, s *session.Session) event.S3Reader
	// 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{
            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")
            },
            DoGetImageAPIFunc: func(ctx context.Context, cfg *config.Config) event.ImageAPIClient {
	               panic("mock out the DoGetImageAPI method")
            },
            DoGetKafkaConsumerFunc: func(ctx context.Context, cfg *config.Config) (kafka.IConsumerGroup, error) {
	               panic("mock out the DoGetKafkaConsumer method")
            },
            DoGetS3ClientFunc: func(awsRegion string, bucketName string, encryptionEnabled bool) (event.S3Writer, error) {
	               panic("mock out the DoGetS3Client method")
            },
            DoGetS3ClientWithSessionFunc: func(bucketName string, encryptionEnabled bool, s *session.Session) event.S3Reader {
	               panic("mock out the DoGetS3ClientWithSession method")
            },
        }

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

    }

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) DoGetImageAPI added in v0.3.0

func (mock *InitialiserMock) DoGetImageAPI(ctx context.Context, cfg *config.Config) event.ImageAPIClient

DoGetImageAPI calls DoGetImageAPIFunc.

func (*InitialiserMock) DoGetImageAPICalls added in v0.3.0

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

DoGetImageAPICalls gets all the calls that were made to DoGetImageAPI. Check the length with:

len(mockedInitialiser.DoGetImageAPICalls())

func (*InitialiserMock) DoGetKafkaConsumer added in v0.4.0

func (mock *InitialiserMock) DoGetKafkaConsumer(ctx context.Context, cfg *config.Config) (kafka.IConsumerGroup, error)

DoGetKafkaConsumer calls DoGetKafkaConsumerFunc.

func (*InitialiserMock) DoGetKafkaConsumerCalls added in v0.4.0

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

DoGetKafkaConsumerCalls gets all the calls that were made to DoGetKafkaConsumer. Check the length with:

len(mockedInitialiser.DoGetKafkaConsumerCalls())

func (*InitialiserMock) DoGetS3Client added in v0.6.0

func (mock *InitialiserMock) DoGetS3Client(awsRegion string, bucketName string) (event.S3Writer, error)

DoGetS3Client calls DoGetS3ClientFunc.

func (*InitialiserMock) DoGetS3ClientCalls added in v0.6.0

func (mock *InitialiserMock) DoGetS3ClientCalls() []struct {
	AwsRegion  string
	BucketName string
}

DoGetS3ClientCalls gets all the calls that were made to DoGetS3Client. Check the length with:

len(mockedInitialiser.DoGetS3ClientCalls())

func (*InitialiserMock) DoGetS3ClientWithSession added in v0.6.0

func (mock *InitialiserMock) DoGetS3ClientWithSession(bucketName string, s *session.Session) event.S3Reader

DoGetS3ClientWithSession calls DoGetS3ClientWithSessionFunc.

func (*InitialiserMock) DoGetS3ClientWithSessionCalls added in v0.6.0

func (mock *InitialiserMock) DoGetS3ClientWithSessionCalls() []struct {
	BucketName string
	S          *session.Session
}

DoGetS3ClientWithSessionCalls gets all the calls that were made to DoGetS3ClientWithSession. Check the length with:

len(mockedInitialiser.DoGetS3ClientWithSessionCalls())

Jump to

Keyboard shortcuts

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