mock

package
v0.0.0-...-87f5b26 Latest Latest
Warning

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

Go to latest
Published: Jul 31, 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 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 MongoDBMock

type MongoDBMock struct {
	// AddEventToFilterOutputFunc mocks the AddEventToFilterOutput method.
	AddEventToFilterOutputFunc func(ctx context.Context, filterOutputID string, event *models.Event) error

	// AddFilterFunc mocks the AddFilter method.
	AddFilterFunc func(ctx context.Context, filter *models.Filter) (*models.Filter, error)

	// AddFilterDimensionFunc mocks the AddFilterDimension method.
	AddFilterDimensionFunc func(ctx context.Context, filterID string, name string, options []string, dimensions []models.Dimension, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// AddFilterDimensionOptionFunc mocks the AddFilterDimensionOption method.
	AddFilterDimensionOptionFunc func(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// AddFilterDimensionOptionsFunc mocks the AddFilterDimensionOptions method.
	AddFilterDimensionOptionsFunc func(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, 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

	// CreateFilterOutputFunc mocks the CreateFilterOutput method.
	CreateFilterOutputFunc func(ctx context.Context, filter *models.Filter) error

	// GetFilterFunc mocks the GetFilter method.
	GetFilterFunc func(ctx context.Context, filterID string, eTagSelector string) (*models.Filter, error)

	// GetFilterDimensionFunc mocks the GetFilterDimension method.
	GetFilterDimensionFunc func(ctx context.Context, filterID string, name string, eTagSelector string) (*models.Dimension, error)

	// GetFilterOutputFunc mocks the GetFilterOutput method.
	GetFilterOutputFunc func(ctx context.Context, filterOutputID string) (*models.Filter, error)

	// RemoveFilterDimensionFunc mocks the RemoveFilterDimension method.
	RemoveFilterDimensionFunc func(ctx context.Context, filterID string, name string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// RemoveFilterDimensionOptionFunc mocks the RemoveFilterDimensionOption method.
	RemoveFilterDimensionOptionFunc func(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// RemoveFilterDimensionOptionsFunc mocks the RemoveFilterDimensionOptions method.
	RemoveFilterDimensionOptionsFunc func(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// RunTransactionFunc mocks the RunTransaction method.
	RunTransactionFunc func(ctx context.Context, retry bool, fn mongodriver.TransactionFunc) (interface{}, error)

	// UpdateFilterFunc mocks the UpdateFilter method.
	UpdateFilterFunc func(ctx context.Context, updatedFilter *models.Filter, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

	// UpdateFilterOutputFunc mocks the UpdateFilterOutput method.
	UpdateFilterOutputFunc func(ctx context.Context, filter *models.Filter, timestamp primitive.Timestamp) error
	// contains filtered or unexported fields
}

MongoDBMock is a mock implementation of service.MongoDB.

func TestSomethingThatUsesMongoDB(t *testing.T) {

	// make and configure a mocked service.MongoDB
	mockedMongoDB := &MongoDBMock{
		AddEventToFilterOutputFunc: func(ctx context.Context, filterOutputID string, event *models.Event) error {
			panic("mock out the AddEventToFilterOutput method")
		},
		AddFilterFunc: func(ctx context.Context, filter *models.Filter) (*models.Filter, error) {
			panic("mock out the AddFilter method")
		},
		AddFilterDimensionFunc: func(ctx context.Context, filterID string, name string, options []string, dimensions []models.Dimension, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the AddFilterDimension method")
		},
		AddFilterDimensionOptionFunc: func(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the AddFilterDimensionOption method")
		},
		AddFilterDimensionOptionsFunc: func(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the AddFilterDimensionOptions 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")
		},
		CreateFilterOutputFunc: func(ctx context.Context, filter *models.Filter) error {
			panic("mock out the CreateFilterOutput method")
		},
		GetFilterFunc: func(ctx context.Context, filterID string, eTagSelector string) (*models.Filter, error) {
			panic("mock out the GetFilter method")
		},
		GetFilterDimensionFunc: func(ctx context.Context, filterID string, name string, eTagSelector string) (*models.Dimension, error) {
			panic("mock out the GetFilterDimension method")
		},
		GetFilterOutputFunc: func(ctx context.Context, filterOutputID string) (*models.Filter, error) {
			panic("mock out the GetFilterOutput method")
		},
		RemoveFilterDimensionFunc: func(ctx context.Context, filterID string, name string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the RemoveFilterDimension method")
		},
		RemoveFilterDimensionOptionFunc: func(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the RemoveFilterDimensionOption method")
		},
		RemoveFilterDimensionOptionsFunc: func(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the RemoveFilterDimensionOptions method")
		},
		RunTransactionFunc: func(ctx context.Context, retry bool, fn mongodriver.TransactionFunc) (interface{}, error) {
			panic("mock out the RunTransaction method")
		},
		UpdateFilterFunc: func(ctx context.Context, updatedFilter *models.Filter, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error) {
			panic("mock out the UpdateFilter method")
		},
		UpdateFilterOutputFunc: func(ctx context.Context, filter *models.Filter, timestamp primitive.Timestamp) error {
			panic("mock out the UpdateFilterOutput method")
		},
	}

	// use mockedMongoDB in code that requires service.MongoDB
	// and then make assertions.

}

func (*MongoDBMock) AddEventToFilterOutput

func (mock *MongoDBMock) AddEventToFilterOutput(ctx context.Context, filterOutputID string, event *models.Event) error

AddEventToFilterOutput calls AddEventToFilterOutputFunc.

func (*MongoDBMock) AddEventToFilterOutputCalls

func (mock *MongoDBMock) AddEventToFilterOutputCalls() []struct {
	Ctx            context.Context
	FilterOutputID string
	Event          *models.Event
}

AddEventToFilterOutputCalls gets all the calls that were made to AddEventToFilterOutput. Check the length with:

len(mockedMongoDB.AddEventToFilterOutputCalls())

func (*MongoDBMock) AddFilter

func (mock *MongoDBMock) AddFilter(ctx context.Context, filter *models.Filter) (*models.Filter, error)

AddFilter calls AddFilterFunc.

func (*MongoDBMock) AddFilterCalls

func (mock *MongoDBMock) AddFilterCalls() []struct {
	Ctx    context.Context
	Filter *models.Filter
}

AddFilterCalls gets all the calls that were made to AddFilter. Check the length with:

len(mockedMongoDB.AddFilterCalls())

func (*MongoDBMock) AddFilterDimension

func (mock *MongoDBMock) AddFilterDimension(ctx context.Context, filterID string, name string, options []string, dimensions []models.Dimension, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

AddFilterDimension calls AddFilterDimensionFunc.

func (*MongoDBMock) AddFilterDimensionCalls

func (mock *MongoDBMock) AddFilterDimensionCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Options       []string
	Dimensions    []models.Dimension
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

AddFilterDimensionCalls gets all the calls that were made to AddFilterDimension. Check the length with:

len(mockedMongoDB.AddFilterDimensionCalls())

func (*MongoDBMock) AddFilterDimensionOption

func (mock *MongoDBMock) AddFilterDimensionOption(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

AddFilterDimensionOption calls AddFilterDimensionOptionFunc.

func (*MongoDBMock) AddFilterDimensionOptionCalls

func (mock *MongoDBMock) AddFilterDimensionOptionCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Option        string
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

AddFilterDimensionOptionCalls gets all the calls that were made to AddFilterDimensionOption. Check the length with:

len(mockedMongoDB.AddFilterDimensionOptionCalls())

func (*MongoDBMock) AddFilterDimensionOptions

func (mock *MongoDBMock) AddFilterDimensionOptions(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

AddFilterDimensionOptions calls AddFilterDimensionOptionsFunc.

func (*MongoDBMock) AddFilterDimensionOptionsCalls

func (mock *MongoDBMock) AddFilterDimensionOptionsCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Options       []string
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

AddFilterDimensionOptionsCalls gets all the calls that were made to AddFilterDimensionOptions. Check the length with:

len(mockedMongoDB.AddFilterDimensionOptionsCalls())

func (*MongoDBMock) Checker

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

Checker calls CheckerFunc.

func (*MongoDBMock) CheckerCalls

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

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

len(mockedMongoDB.CheckerCalls())

func (*MongoDBMock) Close

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

Close calls CloseFunc.

func (*MongoDBMock) CloseCalls

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

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

len(mockedMongoDB.CloseCalls())

func (*MongoDBMock) CreateFilterOutput

func (mock *MongoDBMock) CreateFilterOutput(ctx context.Context, filter *models.Filter) error

CreateFilterOutput calls CreateFilterOutputFunc.

func (*MongoDBMock) CreateFilterOutputCalls

func (mock *MongoDBMock) CreateFilterOutputCalls() []struct {
	Ctx    context.Context
	Filter *models.Filter
}

CreateFilterOutputCalls gets all the calls that were made to CreateFilterOutput. Check the length with:

len(mockedMongoDB.CreateFilterOutputCalls())

func (*MongoDBMock) GetFilter

func (mock *MongoDBMock) GetFilter(ctx context.Context, filterID string, eTagSelector string) (*models.Filter, error)

GetFilter calls GetFilterFunc.

func (*MongoDBMock) GetFilterCalls

func (mock *MongoDBMock) GetFilterCalls() []struct {
	Ctx          context.Context
	FilterID     string
	ETagSelector string
}

GetFilterCalls gets all the calls that were made to GetFilter. Check the length with:

len(mockedMongoDB.GetFilterCalls())

func (*MongoDBMock) GetFilterDimension

func (mock *MongoDBMock) GetFilterDimension(ctx context.Context, filterID string, name string, eTagSelector string) (*models.Dimension, error)

GetFilterDimension calls GetFilterDimensionFunc.

func (*MongoDBMock) GetFilterDimensionCalls

func (mock *MongoDBMock) GetFilterDimensionCalls() []struct {
	Ctx          context.Context
	FilterID     string
	Name         string
	ETagSelector string
}

GetFilterDimensionCalls gets all the calls that were made to GetFilterDimension. Check the length with:

len(mockedMongoDB.GetFilterDimensionCalls())

func (*MongoDBMock) GetFilterOutput

func (mock *MongoDBMock) GetFilterOutput(ctx context.Context, filterOutputID string) (*models.Filter, error)

GetFilterOutput calls GetFilterOutputFunc.

func (*MongoDBMock) GetFilterOutputCalls

func (mock *MongoDBMock) GetFilterOutputCalls() []struct {
	Ctx            context.Context
	FilterOutputID string
}

GetFilterOutputCalls gets all the calls that were made to GetFilterOutput. Check the length with:

len(mockedMongoDB.GetFilterOutputCalls())

func (*MongoDBMock) RemoveFilterDimension

func (mock *MongoDBMock) RemoveFilterDimension(ctx context.Context, filterID string, name string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

RemoveFilterDimension calls RemoveFilterDimensionFunc.

func (*MongoDBMock) RemoveFilterDimensionCalls

func (mock *MongoDBMock) RemoveFilterDimensionCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

RemoveFilterDimensionCalls gets all the calls that were made to RemoveFilterDimension. Check the length with:

len(mockedMongoDB.RemoveFilterDimensionCalls())

func (*MongoDBMock) RemoveFilterDimensionOption

func (mock *MongoDBMock) RemoveFilterDimensionOption(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

RemoveFilterDimensionOption calls RemoveFilterDimensionOptionFunc.

func (*MongoDBMock) RemoveFilterDimensionOptionCalls

func (mock *MongoDBMock) RemoveFilterDimensionOptionCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Option        string
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

RemoveFilterDimensionOptionCalls gets all the calls that were made to RemoveFilterDimensionOption. Check the length with:

len(mockedMongoDB.RemoveFilterDimensionOptionCalls())

func (*MongoDBMock) RemoveFilterDimensionOptions

func (mock *MongoDBMock) RemoveFilterDimensionOptions(ctx context.Context, filterID string, name string, options []string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

RemoveFilterDimensionOptions calls RemoveFilterDimensionOptionsFunc.

func (*MongoDBMock) RemoveFilterDimensionOptionsCalls

func (mock *MongoDBMock) RemoveFilterDimensionOptionsCalls() []struct {
	Ctx           context.Context
	FilterID      string
	Name          string
	Options       []string
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

RemoveFilterDimensionOptionsCalls gets all the calls that were made to RemoveFilterDimensionOptions. Check the length with:

len(mockedMongoDB.RemoveFilterDimensionOptionsCalls())

func (*MongoDBMock) RunTransaction

func (mock *MongoDBMock) RunTransaction(ctx context.Context, retry bool, fn mongodriver.TransactionFunc) (interface{}, error)

RunTransaction calls RunTransactionFunc.

func (*MongoDBMock) RunTransactionCalls

func (mock *MongoDBMock) RunTransactionCalls() []struct {
	Ctx   context.Context
	Retry bool
	Fn    mongodriver.TransactionFunc
}

RunTransactionCalls gets all the calls that were made to RunTransaction. Check the length with:

len(mockedMongoDB.RunTransactionCalls())

func (*MongoDBMock) UpdateFilter

func (mock *MongoDBMock) UpdateFilter(ctx context.Context, updatedFilter *models.Filter, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (string, error)

UpdateFilter calls UpdateFilterFunc.

func (*MongoDBMock) UpdateFilterCalls

func (mock *MongoDBMock) UpdateFilterCalls() []struct {
	Ctx           context.Context
	UpdatedFilter *models.Filter
	Timestamp     primitive.Timestamp
	ETagSelector  string
	CurrentFilter *models.Filter
}

UpdateFilterCalls gets all the calls that were made to UpdateFilter. Check the length with:

len(mockedMongoDB.UpdateFilterCalls())

func (*MongoDBMock) UpdateFilterOutput

func (mock *MongoDBMock) UpdateFilterOutput(ctx context.Context, filter *models.Filter, timestamp primitive.Timestamp) error

UpdateFilterOutput calls UpdateFilterOutputFunc.

func (*MongoDBMock) UpdateFilterOutputCalls

func (mock *MongoDBMock) UpdateFilterOutputCalls() []struct {
	Ctx       context.Context
	Filter    *models.Filter
	Timestamp primitive.Timestamp
}

UpdateFilterOutputCalls gets all the calls that were made to UpdateFilterOutput. Check the length with:

len(mockedMongoDB.UpdateFilterOutputCalls())

Jump to

Keyboard shortcuts

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