mock

package
v1.43.1 Latest Latest
Warning

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

Go to latest
Published: Mar 7, 2024 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 DatasetAPIClientMock

type DatasetAPIClientMock struct {
	// GetDatasetsFunc mocks the GetDatasets method.
	GetDatasetsFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, q *datasetclient.QueryParams) (datasetclient.List, error)

	// GetEditionsFunc mocks the GetEditions method.
	GetEditionsFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.Edition, error)

	// GetFullEditionsDetailsFunc mocks the GetFullEditionsDetails method.
	GetFullEditionsDetailsFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.EditionsDetails, error)

	// GetVersionMetadataFunc mocks the GetVersionMetadata method.
	GetVersionMetadataFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (datasetclient.Metadata, error)
	// contains filtered or unexported fields
}

DatasetAPIClientMock is a mock implementation of clients.DatasetAPIClient.

func TestSomethingThatUsesDatasetAPIClient(t *testing.T) {

	// make and configure a mocked clients.DatasetAPIClient
	mockedDatasetAPIClient := &DatasetAPIClientMock{
		GetDatasetsFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, q *datasetclient.QueryParams) (datasetclient.List, error) {
			panic("mock out the GetDatasets method")
		},
		GetEditionsFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.Edition, error) {
			panic("mock out the GetEditions method")
		},
		GetFullEditionsDetailsFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.EditionsDetails, error) {
			panic("mock out the GetFullEditionsDetails method")
		},
		GetVersionMetadataFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (datasetclient.Metadata, error) {
			panic("mock out the GetVersionMetadata method")
		},
	}

	// use mockedDatasetAPIClient in code that requires clients.DatasetAPIClient
	// and then make assertions.

}

func (*DatasetAPIClientMock) GetDatasets

func (mock *DatasetAPIClientMock) GetDatasets(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, q *datasetclient.QueryParams) (datasetclient.List, error)

GetDatasets calls GetDatasetsFunc.

func (*DatasetAPIClientMock) GetDatasetsCalls

func (mock *DatasetAPIClientMock) GetDatasetsCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	Q                *datasetclient.QueryParams
}

GetDatasetsCalls gets all the calls that were made to GetDatasets. Check the length with:

len(mockedDatasetAPIClient.GetDatasetsCalls())

func (*DatasetAPIClientMock) GetEditions

func (mock *DatasetAPIClientMock) GetEditions(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.Edition, error)

GetEditions calls GetEditionsFunc.

func (*DatasetAPIClientMock) GetEditionsCalls

func (mock *DatasetAPIClientMock) GetEditionsCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	DatasetID        string
}

GetEditionsCalls gets all the calls that were made to GetEditions. Check the length with:

len(mockedDatasetAPIClient.GetEditionsCalls())

func (*DatasetAPIClientMock) GetFullEditionsDetails

func (mock *DatasetAPIClientMock) GetFullEditionsDetails(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string) ([]datasetclient.EditionsDetails, error)

GetFullEditionsDetails calls GetFullEditionsDetailsFunc.

func (*DatasetAPIClientMock) GetFullEditionsDetailsCalls

func (mock *DatasetAPIClientMock) GetFullEditionsDetailsCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	DatasetID        string
}

GetFullEditionsDetailsCalls gets all the calls that were made to GetFullEditionsDetails. Check the length with:

len(mockedDatasetAPIClient.GetFullEditionsDetailsCalls())

func (*DatasetAPIClientMock) GetVersionMetadata

func (mock *DatasetAPIClientMock) GetVersionMetadata(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (datasetclient.Metadata, error)

GetVersionMetadata calls GetVersionMetadataFunc.

func (*DatasetAPIClientMock) GetVersionMetadataCalls

func (mock *DatasetAPIClientMock) GetVersionMetadataCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	ID               string
	Edition          string
	Version          string
}

GetVersionMetadataCalls gets all the calls that were made to GetVersionMetadata. Check the length with:

len(mockedDatasetAPIClient.GetVersionMetadataCalls())

type ElasticSearchMock

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

	// BulkIndexAddFunc mocks the BulkIndexAdd method.
	BulkIndexAddFunc func(ctx context.Context, action dpEsClient.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 dpEsClient.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 []dpEsClient.Search, queryParams *dpEsClient.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 dpEsClient.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 clients.ElasticSearch.

func TestSomethingThatUsesElasticSearch(t *testing.T) {

	// make and configure a mocked clients.ElasticSearch
	mockedElasticSearch := &ElasticSearchMock{
		AddDocumentFunc: func(ctx context.Context, indexName string, documentID string, document []byte, opts *dpEsClient.AddDocumentOptions) error {
			panic("mock out the AddDocument method")
		},
		BulkIndexAddFunc: func(ctx context.Context, action dpEsClient.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 dpEsClient.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 []dpEsClient.Search, queryParams *dpEsClient.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 dpEsClient.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 clients.ElasticSearch
	// and then make assertions.

}

func (*ElasticSearchMock) AddDocument

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

AddDocument calls AddDocumentFunc.

func (*ElasticSearchMock) AddDocumentCalls

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

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

len(mockedElasticSearch.AddDocumentCalls())

func (*ElasticSearchMock) BulkIndexAdd

func (mock *ElasticSearchMock) BulkIndexAdd(ctx context.Context, action dpEsClient.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

func (mock *ElasticSearchMock) BulkIndexAddCalls() []struct {
	Ctx        context.Context
	Action     dpEsClient.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

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

BulkIndexClose calls BulkIndexCloseFunc.

func (*ElasticSearchMock) BulkIndexCloseCalls

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

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

BulkUpdate calls BulkUpdateFunc.

func (*ElasticSearchMock) BulkUpdateCalls

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

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

Checker calls CheckerFunc.

func (*ElasticSearchMock) CheckerCalls

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

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

Count calls CountFunc.

func (*ElasticSearchMock) CountCalls

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

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

len(mockedElasticSearch.CountCalls())

func (*ElasticSearchMock) CountIndices

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

CountIndices calls CountIndicesFunc.

func (*ElasticSearchMock) CountIndicesCalls

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

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

CreateIndex calls CreateIndexFunc.

func (*ElasticSearchMock) CreateIndexCalls

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

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

DeleteIndex calls DeleteIndexFunc.

func (*ElasticSearchMock) DeleteIndexCalls

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

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

DeleteIndices calls DeleteIndicesFunc.

func (*ElasticSearchMock) DeleteIndicesCalls

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

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

GetAlias calls GetAliasFunc.

func (*ElasticSearchMock) GetAliasCalls

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

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

GetIndices calls GetIndicesFunc.

func (*ElasticSearchMock) GetIndicesCalls

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

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

MultiSearch calls MultiSearchFunc.

func (*ElasticSearchMock) MultiSearchCalls

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

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

len(mockedElasticSearch.MultiSearchCalls())

func (*ElasticSearchMock) NewBulkIndexer

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

NewBulkIndexer calls NewBulkIndexerFunc.

func (*ElasticSearchMock) NewBulkIndexerCalls

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

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

Search calls SearchFunc.

func (*ElasticSearchMock) SearchCalls

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

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

len(mockedElasticSearch.SearchCalls())

func (*ElasticSearchMock) UpdateAliases

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

UpdateAliases calls UpdateAliasesFunc.

func (*ElasticSearchMock) UpdateAliasesCalls

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 ZebedeeClientMock

type ZebedeeClientMock struct {
	// GetPublishedDataFunc mocks the GetPublishedData method.
	GetPublishedDataFunc func(ctx context.Context, uriString string) ([]byte, error)

	// GetPublishedIndexFunc mocks the GetPublishedIndex method.
	GetPublishedIndexFunc func(ctx context.Context, piRequest *zebedee.PublishedIndexRequestParams) (zebedee.PublishedIndex, error)
	// contains filtered or unexported fields
}

ZebedeeClientMock is a mock implementation of clients.ZebedeeClient.

func TestSomethingThatUsesZebedeeClient(t *testing.T) {

	// make and configure a mocked clients.ZebedeeClient
	mockedZebedeeClient := &ZebedeeClientMock{
		GetPublishedDataFunc: func(ctx context.Context, uriString string) ([]byte, error) {
			panic("mock out the GetPublishedData method")
		},
		GetPublishedIndexFunc: func(ctx context.Context, piRequest *zebedee.PublishedIndexRequestParams) (zebedee.PublishedIndex, error) {
			panic("mock out the GetPublishedIndex method")
		},
	}

	// use mockedZebedeeClient in code that requires clients.ZebedeeClient
	// and then make assertions.

}

func (*ZebedeeClientMock) GetPublishedData

func (mock *ZebedeeClientMock) GetPublishedData(ctx context.Context, uriString string) ([]byte, error)

GetPublishedData calls GetPublishedDataFunc.

func (*ZebedeeClientMock) GetPublishedDataCalls

func (mock *ZebedeeClientMock) GetPublishedDataCalls() []struct {
	Ctx       context.Context
	UriString string
}

GetPublishedDataCalls gets all the calls that were made to GetPublishedData. Check the length with:

len(mockedZebedeeClient.GetPublishedDataCalls())

func (*ZebedeeClientMock) GetPublishedIndex

GetPublishedIndex calls GetPublishedIndexFunc.

func (*ZebedeeClientMock) GetPublishedIndexCalls

func (mock *ZebedeeClientMock) GetPublishedIndexCalls() []struct {
	Ctx       context.Context
	PiRequest *zebedee.PublishedIndexRequestParams
}

GetPublishedIndexCalls gets all the calls that were made to GetPublishedIndex. Check the length with:

len(mockedZebedeeClient.GetPublishedIndexCalls())

Jump to

Keyboard shortcuts

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