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: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var TestETag = "testETag"

TestETag represents an mocked base value for ETags

Functions

func GenerateMocksForMiddleware

func GenerateMocksForMiddleware(flexCode int, datasetVersion int, filterType string) (*apimock.FilterFlexAPIMock, *apimock.DataStoreMock)

Types

type DataStore

type DataStore struct {
	Cfg  DataStoreConfig
	Mock *apimock.DataStoreMock
	// contains filtered or unexported fields
}

DataStore holds the list of possible error flats along with the mocked datastore. This struct can be used directly as a mock, as it implements the required methods, or you can use the internal 'moq' Mock if you want ot validate calls, parameters etc.

func NewDataStore

func NewDataStore() *DataStore

NewDataStore creates a new datastore mock with an empty config

func (*DataStore) AddEventToFilterOutput

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

AddEventToFilterOutput adds the given event to the filter output of the given ID

func (*DataStore) AddFilter

func (ds *DataStore) AddFilter(ctx context.Context, filterJob *models.Filter) (*models.Filter, error)

AddFilter represents the mocked version of creating a filter blueprint to the datastore

func (*DataStore) AddFilterDimension

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

AddFilterDimension represents the mocked version of creating a filter dimension to the datastore

func (*DataStore) AddFilterDimensionOption

func (ds *DataStore) AddFilterDimensionOption(ctx context.Context, filterID, name, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (newETag string, err error)

AddFilterDimensionOption represents the mocked version of creating a filter dimension option to the datastore

func (*DataStore) AddFilterDimensionOptions

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

AddFilterDimensionOptions represents the mocked version of adding a list of dimension options to the datastore

func (*DataStore) AgeDimension

func (ds *DataStore) AgeDimension() *DataStore

AgeDimension sets AgeDimension flag to true

func (*DataStore) BadRequest

func (ds *DataStore) BadRequest() *DataStore

BadRequest sets BadRequest flag to true

func (*DataStore) ChangeInstanceRequest

func (ds *DataStore) ChangeInstanceRequest() *DataStore

ChangeInstanceRequest sets ChangeInstanceRequest flag to true

func (*DataStore) ConflictRequest

func (ds *DataStore) ConflictRequest() *DataStore

ConflictRequest sets ConflictRequest flag to true

func (*DataStore) CreateFilterOutput

func (ds *DataStore) CreateFilterOutput(ctx context.Context, filterJob *models.Filter) error

CreateFilterOutput represents the mocked version of creating a filter output to the datastore

func (*DataStore) DimensionNotFound

func (ds *DataStore) DimensionNotFound() *DataStore

DimensionNotFound sets DimensionNotFound flag to true

func (*DataStore) GetFilter

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

GetFilter represents the mocked version of getting a filter blueprint from the datastore

func (*DataStore) GetFilterDimension

func (ds *DataStore) GetFilterDimension(ctx context.Context, filterID string, name, eTagSelector string) (dimension *models.Dimension, err error)

GetFilterDimension represents the mocked version of getting a filter dimension from the datastore

func (*DataStore) GetFilterOutput

func (ds *DataStore) GetFilterOutput(ctx context.Context, filterID string) (*models.Filter, error)

GetFilterOutput represents the mocked version of getting a filter output from the datastore

func (*DataStore) InternalError

func (ds *DataStore) InternalError() *DataStore

InternalError sets InternalError flag to true

func (*DataStore) InvalidDimensionOption

func (ds *DataStore) InvalidDimensionOption() *DataStore

InvalidDimensionOption sets InvalidDimensionOption flag to true

func (ds *DataStore) MissingPublicLinks() *DataStore

MissingPublicLinks sets MissingPublicLinks flag to true

func (*DataStore) NotFound

func (ds *DataStore) NotFound() *DataStore

NotFound sets NotFound flag to true

func (*DataStore) OptionNotFound

func (ds *DataStore) OptionNotFound() *DataStore

OptionNotFound sets OptionNotFound flag to true

func (*DataStore) RemoveFilterDimension

func (ds *DataStore) RemoveFilterDimension(ctx context.Context, filterID, name string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (newETag string, err error)

RemoveFilterDimension represents the mocked version of removing a filter dimension from the datastore

func (*DataStore) RemoveFilterDimensionOption

func (ds *DataStore) RemoveFilterDimensionOption(ctx context.Context, filterID string, name string, option string, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (newETag string, err error)

RemoveFilterDimensionOption represents the mocked version of removing a filter dimension option from the datastore

func (*DataStore) RemoveFilterDimensionOptions

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

RemoveFilterDimensionOptions represents the mocked version of removing a set of filter dimension options from the datastore

func (*DataStore) RunTransaction

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

func (*DataStore) Unpublished

func (ds *DataStore) Unpublished() *DataStore

Unpublished sets Unpublished flag to true

func (*DataStore) UpdateFilter

func (ds *DataStore) UpdateFilter(ctx context.Context, updatedFilter *models.Filter, timestamp primitive.Timestamp, eTagSelector string, currentFilter *models.Filter) (newETag string, err error)

UpdateFilter represents the mocked version of updating a filter blueprint from the datastore

func (*DataStore) UpdateFilterOutput

func (ds *DataStore) UpdateFilterOutput(ctx context.Context, filterJob *models.Filter, timestamp primitive.Timestamp) error

UpdateFilterOutput represents the mocked version of updating a filter output from the datastore

func (*DataStore) VersionNotFound

func (ds *DataStore) VersionNotFound() *DataStore

VersionNotFound sets VersionNotFound flag to true

type DataStoreConfig

type DataStoreConfig struct {
	NotFound               bool
	DimensionNotFound      bool
	OptionNotFound         bool
	VersionNotFound        bool
	InternalError          bool
	ChangeInstanceRequest  bool
	InvalidDimensionOption bool
	Unpublished            bool
	MissingPublicLinks     bool
	BadRequest             bool
	ConflictRequest        bool
	AgeDimension           bool
}

DataStoreConfig represents a list of error flags to set error in mocked datastore

type DatasetAPI

type DatasetAPI struct {
	Cfg  DatasetAPIConfig
	Mock *apimock.DatasetAPIMock
}

DatasetAPI holds the list of possible error flats along with the mocked dataset api calls. This struct can be used directly as a mock, as it implements the required methods, or you can use the internal 'moq' Mock if you want ot validate calls, parameters etc.

func NewDatasetAPI

func NewDatasetAPI() *DatasetAPI

NewDatasetAPI creates a new dataset API mock with an empty config

func (*DatasetAPI) Get

func (ds *DatasetAPI) Get(ctx context.Context, userToken, svcToken, collectionID, datasetID string) (dataset.DatasetDetails, error)

func (*DatasetAPI) GetOptionsBatchProcess

func (ds *DatasetAPI) GetOptionsBatchProcess(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version, dimension string, optionIDs *[]string, processBatch dataset.OptionsBatchProcessor, batchSize int, maxWorkers int) (err error)

GetOptionsBatchProcess represents the mocked version of getting a list of dimension options from the dataset API

func (*DatasetAPI) GetVersion

func (ds *DatasetAPI) GetVersion(ctx context.Context, userAuthToken, serviceAuthToken, downloadServiceAuthToken, collectionID, datasetID, edition, version string) (m dataset.Version, err error)

GetVersion represents the mocked version of getting an version document from dataset API

func (*DatasetAPI) GetVersionDimensions

func (ds *DatasetAPI) GetVersionDimensions(ctx context.Context, userAuthToken, serviceAuthToken, collectionID, id, edition, version string) (m dataset.VersionDimensions, err error)

GetVersionDimensions represents the mocked version of getting a list of dimensions from the dataset API

func (*DatasetAPI) InternalServiceError

func (ds *DatasetAPI) InternalServiceError() *DatasetAPI

InternalServiceError sets InternalServiceError flag to true

func (*DatasetAPI) Unpublished

func (ds *DatasetAPI) Unpublished() *DatasetAPI

Unpublished sets Unpublished flag to true

func (*DatasetAPI) VersionNotFound

func (ds *DatasetAPI) VersionNotFound() *DatasetAPI

VersionNotFound sets VersionNotFound flag to true

type DatasetAPIConfig

type DatasetAPIConfig struct {
	VersionNotFound     bool
	InternalServerError bool
	Unpublished         bool
}

DatasetAPIConfig represents a list of error flags to set error in mocked dataset API

type FilterJob

type FilterJob struct {
	ReturnError bool
}

FilterJob contains a flag indicating whether the job has failed or not

func (*FilterJob) Queue

func (fj *FilterJob) Queue(filter *models.Filter) error

Queue checks whether the filter job has errored

type MessageData

type MessageData struct {
	FilterJobID string
}

MessageData contains the unique identifier for the filter job

Jump to

Keyboard shortcuts

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