mock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: May 19, 2023 License: MIT Imports: 7 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ElasticSearchMock added in v0.13.0

type ElasticSearchMock struct {
	// AddDocumentFunc mocks the AddDocument method.
	AddDocumentFunc func(ctx context.Context, indexName string, documentID string, document []byte, opts *dpelasticsearch.AddDocumentOptions) error

	// BulkIndexAddFunc mocks the BulkIndexAdd method.
	BulkIndexAddFunc func(ctx context.Context, action dpelasticsearch.BulkIndexerAction, index string, documentID string, document []byte, onSuccess func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem), onFailure func(ctx context.Context, bii esutil.BulkIndexerItem, biri esutil.BulkIndexerResponseItem, err error)) error

	// BulkIndexCloseFunc mocks the BulkIndexClose method.
	BulkIndexCloseFunc func(contextMoqParam context.Context) error

	// BulkUpdateFunc mocks the BulkUpdate method.
	BulkUpdateFunc func(ctx context.Context, indexName string, url string, settings []byte) ([]byte, error)

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

	// CountFunc mocks the Count method.
	CountFunc func(ctx context.Context, count dpelasticsearch.Count) ([]byte, error)

	// CountIndicesFunc mocks the CountIndices method.
	CountIndicesFunc func(ctx context.Context, indices []string) ([]byte, error)

	// CreateIndexFunc mocks the CreateIndex method.
	CreateIndexFunc func(ctx context.Context, indexName string, indexSettings []byte) error

	// DeleteIndexFunc mocks the DeleteIndex method.
	DeleteIndexFunc func(ctx context.Context, indexName string) error

	// DeleteIndicesFunc mocks the DeleteIndices method.
	DeleteIndicesFunc func(ctx context.Context, indices []string) error

	// GetAliasFunc mocks the GetAlias method.
	GetAliasFunc func(ctx context.Context) ([]byte, error)

	// GetIndicesFunc mocks the GetIndices method.
	GetIndicesFunc func(ctx context.Context, indexPatterns []string) ([]byte, error)

	// MultiSearchFunc mocks the MultiSearch method.
	MultiSearchFunc func(ctx context.Context, searches []dpelasticsearch.Search, queryParams *dpelasticsearch.QueryParams) ([]byte, error)

	// NewBulkIndexerFunc mocks the NewBulkIndexer method.
	NewBulkIndexerFunc func(contextMoqParam context.Context) error

	// SearchFunc mocks the Search method.
	SearchFunc func(ctx context.Context, search dpelasticsearch.Search) ([]byte, error)

	// UpdateAliasesFunc mocks the UpdateAliases method.
	UpdateAliasesFunc func(ctx context.Context, alias string, removeIndices []string, addIndices []string) error
	// contains filtered or unexported fields
}

ElasticSearchMock is a mock implementation of service.ElasticSearch.

func TestSomethingThatUsesElasticSearch(t *testing.T) {

	// make and configure a mocked service.ElasticSearch
	mockedElasticSearch := &ElasticSearchMock{
		AddDocumentFunc: func(ctx context.Context, indexName string, documentID string, document []byte, opts *dpelasticsearch.AddDocumentOptions) error {
			panic("mock out the AddDocument method")
		},
		BulkIndexAddFunc: func(ctx context.Context, action dpelasticsearch.BulkIndexerAction, index string, documentID string, document []byte, onSuccess func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem), onFailure func(ctx context.Context, bii esutil.BulkIndexerItem, biri esutil.BulkIndexerResponseItem, err error)) error {
			panic("mock out the BulkIndexAdd method")
		},
		BulkIndexCloseFunc: func(contextMoqParam context.Context) error {
			panic("mock out the BulkIndexClose method")
		},
		BulkUpdateFunc: func(ctx context.Context, indexName string, url string, settings []byte) ([]byte, error) {
			panic("mock out the BulkUpdate method")
		},
		CheckerFunc: func(ctx context.Context, state *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		CountFunc: func(ctx context.Context, count dpelasticsearch.Count) ([]byte, error) {
			panic("mock out the Count method")
		},
		CountIndicesFunc: func(ctx context.Context, indices []string) ([]byte, error) {
			panic("mock out the CountIndices method")
		},
		CreateIndexFunc: func(ctx context.Context, indexName string, indexSettings []byte) error {
			panic("mock out the CreateIndex method")
		},
		DeleteIndexFunc: func(ctx context.Context, indexName string) error {
			panic("mock out the DeleteIndex method")
		},
		DeleteIndicesFunc: func(ctx context.Context, indices []string) error {
			panic("mock out the DeleteIndices method")
		},
		GetAliasFunc: func(ctx context.Context) ([]byte, error) {
			panic("mock out the GetAlias method")
		},
		GetIndicesFunc: func(ctx context.Context, indexPatterns []string) ([]byte, error) {
			panic("mock out the GetIndices method")
		},
		MultiSearchFunc: func(ctx context.Context, searches []dpelasticsearch.Search, queryParams *dpelasticsearch.QueryParams) ([]byte, error) {
			panic("mock out the MultiSearch method")
		},
		NewBulkIndexerFunc: func(contextMoqParam context.Context) error {
			panic("mock out the NewBulkIndexer method")
		},
		SearchFunc: func(ctx context.Context, search dpelasticsearch.Search) ([]byte, error) {
			panic("mock out the Search method")
		},
		UpdateAliasesFunc: func(ctx context.Context, alias string, removeIndices []string, addIndices []string) error {
			panic("mock out the UpdateAliases method")
		},
	}

	// use mockedElasticSearch in code that requires service.ElasticSearch
	// and then make assertions.

}

func (*ElasticSearchMock) AddDocument added in v0.13.0

func (mock *ElasticSearchMock) AddDocument(ctx context.Context, indexName string, documentID string, document []byte, opts *dpelasticsearch.AddDocumentOptions) error

AddDocument calls AddDocumentFunc.

func (*ElasticSearchMock) AddDocumentCalls added in v0.13.0

func (mock *ElasticSearchMock) AddDocumentCalls() []struct {
	Ctx        context.Context
	IndexName  string
	DocumentID string
	Document   []byte
	Opts       *dpelasticsearch.AddDocumentOptions
}

AddDocumentCalls gets all the calls that were made to AddDocument. Check the length with:

len(mockedElasticSearch.AddDocumentCalls())

func (*ElasticSearchMock) BulkIndexAdd added in v0.13.0

func (mock *ElasticSearchMock) BulkIndexAdd(ctx context.Context, action dpelasticsearch.BulkIndexerAction, index string, documentID string, document []byte, onSuccess func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem), onFailure func(ctx context.Context, bii esutil.BulkIndexerItem, biri esutil.BulkIndexerResponseItem, err error)) error

BulkIndexAdd calls BulkIndexAddFunc.

func (*ElasticSearchMock) BulkIndexAddCalls added in v0.13.0

func (mock *ElasticSearchMock) BulkIndexAddCalls() []struct {
	Ctx        context.Context
	Action     dpelasticsearch.BulkIndexerAction
	Index      string
	DocumentID string
	Document   []byte
	OnSuccess  func(ctx context.Context, item esutil.BulkIndexerItem, res esutil.BulkIndexerResponseItem)
	OnFailure  func(ctx context.Context, bii esutil.BulkIndexerItem, biri esutil.BulkIndexerResponseItem, err error)
}

BulkIndexAddCalls gets all the calls that were made to BulkIndexAdd. Check the length with:

len(mockedElasticSearch.BulkIndexAddCalls())

func (*ElasticSearchMock) BulkIndexClose added in v0.13.0

func (mock *ElasticSearchMock) BulkIndexClose(contextMoqParam context.Context) error

BulkIndexClose calls BulkIndexCloseFunc.

func (*ElasticSearchMock) BulkIndexCloseCalls added in v0.13.0

func (mock *ElasticSearchMock) BulkIndexCloseCalls() []struct {
	ContextMoqParam context.Context
}

BulkIndexCloseCalls gets all the calls that were made to BulkIndexClose. Check the length with:

len(mockedElasticSearch.BulkIndexCloseCalls())

func (*ElasticSearchMock) BulkUpdate added in v0.13.0

func (mock *ElasticSearchMock) BulkUpdate(ctx context.Context, indexName string, url string, settings []byte) ([]byte, error)

BulkUpdate calls BulkUpdateFunc.

func (*ElasticSearchMock) BulkUpdateCalls added in v0.13.0

func (mock *ElasticSearchMock) BulkUpdateCalls() []struct {
	Ctx       context.Context
	IndexName string
	URL       string
	Settings  []byte
}

BulkUpdateCalls gets all the calls that were made to BulkUpdate. Check the length with:

len(mockedElasticSearch.BulkUpdateCalls())

func (*ElasticSearchMock) Checker added in v0.13.0

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

Checker calls CheckerFunc.

func (*ElasticSearchMock) CheckerCalls added in v0.13.0

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

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

len(mockedElasticSearch.CheckerCalls())

func (*ElasticSearchMock) Count added in v0.13.0

func (mock *ElasticSearchMock) Count(ctx context.Context, count dpelasticsearch.Count) ([]byte, error)

Count calls CountFunc.

func (*ElasticSearchMock) CountCalls added in v0.13.0

func (mock *ElasticSearchMock) CountCalls() []struct {
	Ctx   context.Context
	Count dpelasticsearch.Count
}

CountCalls gets all the calls that were made to Count. Check the length with:

len(mockedElasticSearch.CountCalls())

func (*ElasticSearchMock) CountIndices added in v0.13.0

func (mock *ElasticSearchMock) CountIndices(ctx context.Context, indices []string) ([]byte, error)

CountIndices calls CountIndicesFunc.

func (*ElasticSearchMock) CountIndicesCalls added in v0.13.0

func (mock *ElasticSearchMock) CountIndicesCalls() []struct {
	Ctx     context.Context
	Indices []string
}

CountIndicesCalls gets all the calls that were made to CountIndices. Check the length with:

len(mockedElasticSearch.CountIndicesCalls())

func (*ElasticSearchMock) CreateIndex added in v0.13.0

func (mock *ElasticSearchMock) CreateIndex(ctx context.Context, indexName string, indexSettings []byte) error

CreateIndex calls CreateIndexFunc.

func (*ElasticSearchMock) CreateIndexCalls added in v0.13.0

func (mock *ElasticSearchMock) CreateIndexCalls() []struct {
	Ctx           context.Context
	IndexName     string
	IndexSettings []byte
}

CreateIndexCalls gets all the calls that were made to CreateIndex. Check the length with:

len(mockedElasticSearch.CreateIndexCalls())

func (*ElasticSearchMock) DeleteIndex added in v0.13.0

func (mock *ElasticSearchMock) DeleteIndex(ctx context.Context, indexName string) error

DeleteIndex calls DeleteIndexFunc.

func (*ElasticSearchMock) DeleteIndexCalls added in v0.13.0

func (mock *ElasticSearchMock) DeleteIndexCalls() []struct {
	Ctx       context.Context
	IndexName string
}

DeleteIndexCalls gets all the calls that were made to DeleteIndex. Check the length with:

len(mockedElasticSearch.DeleteIndexCalls())

func (*ElasticSearchMock) DeleteIndices added in v0.13.0

func (mock *ElasticSearchMock) DeleteIndices(ctx context.Context, indices []string) error

DeleteIndices calls DeleteIndicesFunc.

func (*ElasticSearchMock) DeleteIndicesCalls added in v0.13.0

func (mock *ElasticSearchMock) DeleteIndicesCalls() []struct {
	Ctx     context.Context
	Indices []string
}

DeleteIndicesCalls gets all the calls that were made to DeleteIndices. Check the length with:

len(mockedElasticSearch.DeleteIndicesCalls())

func (*ElasticSearchMock) GetAlias added in v0.13.0

func (mock *ElasticSearchMock) GetAlias(ctx context.Context) ([]byte, error)

GetAlias calls GetAliasFunc.

func (*ElasticSearchMock) GetAliasCalls added in v0.13.0

func (mock *ElasticSearchMock) GetAliasCalls() []struct {
	Ctx context.Context
}

GetAliasCalls gets all the calls that were made to GetAlias. Check the length with:

len(mockedElasticSearch.GetAliasCalls())

func (*ElasticSearchMock) GetIndices added in v0.13.0

func (mock *ElasticSearchMock) GetIndices(ctx context.Context, indexPatterns []string) ([]byte, error)

GetIndices calls GetIndicesFunc.

func (*ElasticSearchMock) GetIndicesCalls added in v0.13.0

func (mock *ElasticSearchMock) GetIndicesCalls() []struct {
	Ctx           context.Context
	IndexPatterns []string
}

GetIndicesCalls gets all the calls that were made to GetIndices. Check the length with:

len(mockedElasticSearch.GetIndicesCalls())

func (*ElasticSearchMock) MultiSearch added in v0.13.0

func (mock *ElasticSearchMock) MultiSearch(ctx context.Context, searches []dpelasticsearch.Search, queryParams *dpelasticsearch.QueryParams) ([]byte, error)

MultiSearch calls MultiSearchFunc.

func (*ElasticSearchMock) MultiSearchCalls added in v0.13.0

func (mock *ElasticSearchMock) MultiSearchCalls() []struct {
	Ctx         context.Context
	Searches    []dpelasticsearch.Search
	QueryParams *dpelasticsearch.QueryParams
}

MultiSearchCalls gets all the calls that were made to MultiSearch. Check the length with:

len(mockedElasticSearch.MultiSearchCalls())

func (*ElasticSearchMock) NewBulkIndexer added in v0.13.0

func (mock *ElasticSearchMock) NewBulkIndexer(contextMoqParam context.Context) error

NewBulkIndexer calls NewBulkIndexerFunc.

func (*ElasticSearchMock) NewBulkIndexerCalls added in v0.13.0

func (mock *ElasticSearchMock) NewBulkIndexerCalls() []struct {
	ContextMoqParam context.Context
}

NewBulkIndexerCalls gets all the calls that were made to NewBulkIndexer. Check the length with:

len(mockedElasticSearch.NewBulkIndexerCalls())

func (*ElasticSearchMock) Search added in v0.13.0

func (mock *ElasticSearchMock) Search(ctx context.Context, search dpelasticsearch.Search) ([]byte, error)

Search calls SearchFunc.

func (*ElasticSearchMock) SearchCalls added in v0.13.0

func (mock *ElasticSearchMock) SearchCalls() []struct {
	Ctx    context.Context
	Search dpelasticsearch.Search
}

SearchCalls gets all the calls that were made to Search. Check the length with:

len(mockedElasticSearch.SearchCalls())

func (*ElasticSearchMock) UpdateAliases added in v0.13.0

func (mock *ElasticSearchMock) UpdateAliases(ctx context.Context, alias string, removeIndices []string, addIndices []string) error

UpdateAliases calls UpdateAliasesFunc.

func (*ElasticSearchMock) UpdateAliasesCalls added in v0.13.0

func (mock *ElasticSearchMock) UpdateAliasesCalls() []struct {
	Ctx           context.Context
	Alias         string
	RemoveIndices []string
	AddIndices    []string
}

UpdateAliasesCalls gets all the calls that were made to UpdateAliases. Check the length with:

len(mockedElasticSearch.UpdateAliasesCalls())

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 {
	// AddAndGetCheckFunc mocks the AddAndGetCheck method.
	AddAndGetCheckFunc func(name string, checker healthcheck.Checker) (*healthcheck.Check, 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()

	// SubscribeFunc mocks the Subscribe method.
	SubscribeFunc func(s healthcheck.Subscriber, checks ...*healthcheck.Check)
	// 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{
		AddAndGetCheckFunc: func(name string, checker healthcheck.Checker) (*healthcheck.Check, error) {
			panic("mock out the AddAndGetCheck 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")
		},
		SubscribeFunc: func(s healthcheck.Subscriber, checks ...*healthcheck.Check)  {
			panic("mock out the Subscribe method")
		},
	}

	// use mockedHealthChecker in code that requires service.HealthChecker
	// and then make assertions.

}

func (*HealthCheckerMock) AddAndGetCheck added in v0.13.0

func (mock *HealthCheckerMock) AddAndGetCheck(name string, checker healthcheck.Checker) (*healthcheck.Check, error)

AddAndGetCheck calls AddAndGetCheckFunc.

func (*HealthCheckerMock) AddAndGetCheckCalls added in v0.13.0

func (mock *HealthCheckerMock) AddAndGetCheckCalls() []struct {
	Name    string
	Checker healthcheck.Checker
}

AddAndGetCheckCalls gets all the calls that were made to AddAndGetCheck. Check the length with:

len(mockedHealthChecker.AddAndGetCheckCalls())

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())

func (*HealthCheckerMock) Subscribe added in v0.13.0

func (mock *HealthCheckerMock) Subscribe(s healthcheck.Subscriber, checks ...*healthcheck.Check)

Subscribe calls SubscribeFunc.

func (*HealthCheckerMock) SubscribeCalls added in v0.13.0

func (mock *HealthCheckerMock) SubscribeCalls() []struct {
	S      healthcheck.Subscriber
	Checks []*healthcheck.Check
}

SubscribeCalls gets all the calls that were made to Subscribe. Check the length with:

len(mockedHealthChecker.SubscribeCalls())

Jump to

Keyboard shortcuts

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