eventtest

package
v1.27.0 Latest Latest
Warning

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

Go to latest
Published: Dec 6, 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 DatasetAPIMock

type DatasetAPIMock struct {
	// GetInstanceFunc mocks the GetInstance method.
	GetInstanceFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, instanceID string, ifMatch string) (dataset.Instance, string, error)

	// GetMetadataURLFunc mocks the GetMetadataURL method.
	GetMetadataURLFunc func(id string, edition string, version string) string

	// GetOptionsFunc mocks the GetOptions method.
	GetOptionsFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, q *dataset.QueryParams) (dataset.Options, error)

	// GetOptionsInBatchesFunc mocks the GetOptionsInBatches method.
	GetOptionsInBatchesFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, batchSize int, maxWorkers int) (dataset.Options, error)

	// GetVersionFunc mocks the GetVersion method.
	GetVersionFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, downloadServiceAuthToken string, collectionID string, datasetID string, edition string, version string) (dataset.Version, error)

	// GetVersionDimensionsFunc mocks the GetVersionDimensions method.
	GetVersionDimensionsFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.VersionDimensions, error)

	// GetVersionMetadataFunc mocks the GetVersionMetadata method.
	GetVersionMetadataFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.Metadata, error)

	// PutVersionFunc mocks the PutVersion method.
	PutVersionFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string, edition string, version string, m dataset.Version) error
	// contains filtered or unexported fields
}

DatasetAPIMock is a mock implementation of event.DatasetAPI.

func TestSomethingThatUsesDatasetAPI(t *testing.T) {

	// make and configure a mocked event.DatasetAPI
	mockedDatasetAPI := &DatasetAPIMock{
		GetInstanceFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, instanceID string, ifMatch string) (dataset.Instance, string, error) {
			panic("mock out the GetInstance method")
		},
		GetMetadataURLFunc: func(id string, edition string, version string) string {
			panic("mock out the GetMetadataURL method")
		},
		GetOptionsFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, q *dataset.QueryParams) (dataset.Options, error) {
			panic("mock out the GetOptions method")
		},
		GetOptionsInBatchesFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, batchSize int, maxWorkers int) (dataset.Options, error) {
			panic("mock out the GetOptionsInBatches method")
		},
		GetVersionFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, downloadServiceAuthToken string, collectionID string, datasetID string, edition string, version string) (dataset.Version, error) {
			panic("mock out the GetVersion method")
		},
		GetVersionDimensionsFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.VersionDimensions, error) {
			panic("mock out the GetVersionDimensions method")
		},
		GetVersionMetadataFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.Metadata, error) {
			panic("mock out the GetVersionMetadata method")
		},
		PutVersionFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string, edition string, version string, m dataset.Version) error {
			panic("mock out the PutVersion method")
		},
	}

	// use mockedDatasetAPI in code that requires event.DatasetAPI
	// and then make assertions.

}

func (*DatasetAPIMock) GetInstance

func (mock *DatasetAPIMock) GetInstance(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, instanceID string, ifMatch string) (dataset.Instance, string, error)

GetInstance calls GetInstanceFunc.

func (*DatasetAPIMock) GetInstanceCalls

func (mock *DatasetAPIMock) GetInstanceCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	InstanceID       string
	IfMatch          string
}

GetInstanceCalls gets all the calls that were made to GetInstance. Check the length with:

len(mockedDatasetAPI.GetInstanceCalls())

func (*DatasetAPIMock) GetMetadataURL

func (mock *DatasetAPIMock) GetMetadataURL(id string, edition string, version string) string

GetMetadataURL calls GetMetadataURLFunc.

func (*DatasetAPIMock) GetMetadataURLCalls

func (mock *DatasetAPIMock) GetMetadataURLCalls() []struct {
	ID      string
	Edition string
	Version string
}

GetMetadataURLCalls gets all the calls that were made to GetMetadataURL. Check the length with:

len(mockedDatasetAPI.GetMetadataURLCalls())

func (*DatasetAPIMock) GetOptions added in v1.16.0

func (mock *DatasetAPIMock) GetOptions(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, q *dataset.QueryParams) (dataset.Options, error)

GetOptions calls GetOptionsFunc.

func (*DatasetAPIMock) GetOptionsCalls added in v1.16.0

func (mock *DatasetAPIMock) GetOptionsCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	ID               string
	Edition          string
	Version          string
	Dimension        string
	Q                *dataset.QueryParams
}

GetOptionsCalls gets all the calls that were made to GetOptions. Check the length with:

len(mockedDatasetAPI.GetOptionsCalls())

func (*DatasetAPIMock) GetOptionsInBatches added in v1.17.0

func (mock *DatasetAPIMock) GetOptionsInBatches(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string, dimension string, batchSize int, maxWorkers int) (dataset.Options, error)

GetOptionsInBatches calls GetOptionsInBatchesFunc.

func (*DatasetAPIMock) GetOptionsInBatchesCalls added in v1.17.0

func (mock *DatasetAPIMock) GetOptionsInBatchesCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	ID               string
	Edition          string
	Version          string
	Dimension        string
	BatchSize        int
	MaxWorkers       int
}

GetOptionsInBatchesCalls gets all the calls that were made to GetOptionsInBatches. Check the length with:

len(mockedDatasetAPI.GetOptionsInBatchesCalls())

func (*DatasetAPIMock) GetVersion

func (mock *DatasetAPIMock) GetVersion(ctx context.Context, userAuthToken string, serviceAuthToken string, downloadServiceAuthToken string, collectionID string, datasetID string, edition string, version string) (dataset.Version, error)

GetVersion calls GetVersionFunc.

func (*DatasetAPIMock) GetVersionCalls

func (mock *DatasetAPIMock) GetVersionCalls() []struct {
	Ctx                      context.Context
	UserAuthToken            string
	ServiceAuthToken         string
	DownloadServiceAuthToken string
	CollectionID             string
	DatasetID                string
	Edition                  string
	Version                  string
}

GetVersionCalls gets all the calls that were made to GetVersion. Check the length with:

len(mockedDatasetAPI.GetVersionCalls())

func (*DatasetAPIMock) GetVersionDimensions added in v1.17.0

func (mock *DatasetAPIMock) GetVersionDimensions(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.VersionDimensions, error)

GetVersionDimensions calls GetVersionDimensionsFunc.

func (*DatasetAPIMock) GetVersionDimensionsCalls added in v1.17.0

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

GetVersionDimensionsCalls gets all the calls that were made to GetVersionDimensions. Check the length with:

len(mockedDatasetAPI.GetVersionDimensionsCalls())

func (*DatasetAPIMock) GetVersionMetadata

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

GetVersionMetadata calls GetVersionMetadataFunc.

func (*DatasetAPIMock) GetVersionMetadataCalls

func (mock *DatasetAPIMock) 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(mockedDatasetAPI.GetVersionMetadataCalls())

func (*DatasetAPIMock) PutVersion

func (mock *DatasetAPIMock) PutVersion(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, datasetID string, edition string, version string, m dataset.Version) error

PutVersion calls PutVersionFunc.

func (*DatasetAPIMock) PutVersionCalls

func (mock *DatasetAPIMock) PutVersionCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	DatasetID        string
	Edition          string
	Version          string
	M                dataset.Version
}

PutVersionCalls gets all the calls that were made to PutVersion. Check the length with:

len(mockedDatasetAPI.PutVersionCalls())

type FileStoreMock

type FileStoreMock struct {
	// PutFileFunc mocks the PutFile method.
	PutFileFunc func(ctx context.Context, reader io.Reader, filename string, isPublished bool) (string, error)
	// contains filtered or unexported fields
}

FileStoreMock is a mock implementation of event.FileStore.

func TestSomethingThatUsesFileStore(t *testing.T) {

	// make and configure a mocked event.FileStore
	mockedFileStore := &FileStoreMock{
		PutFileFunc: func(ctx context.Context, reader io.Reader, filename string, isPublished bool) (string, error) {
			panic("mock out the PutFile method")
		},
	}

	// use mockedFileStore in code that requires event.FileStore
	// and then make assertions.

}

func (*FileStoreMock) PutFile

func (mock *FileStoreMock) PutFile(ctx context.Context, reader io.Reader, filename string, isPublished bool) (string, error)

PutFile calls PutFileFunc.

func (*FileStoreMock) PutFileCalls

func (mock *FileStoreMock) PutFileCalls() []struct {
	Ctx         context.Context
	Reader      io.Reader
	Filename    string
	IsPublished bool
}

PutFileCalls gets all the calls that were made to PutFile. Check the length with:

len(mockedFileStore.PutFileCalls())

type FilterStoreMock

type FilterStoreMock struct {
	// GetFilterFunc mocks the GetFilter method.
	GetFilterFunc func(ctx context.Context, filterID string) (*filter.Model, error)

	// PutCSVDataFunc mocks the PutCSVData method.
	PutCSVDataFunc func(ctx context.Context, filterID string, downloadItem filter.Download) error

	// PutStateAsEmptyFunc mocks the PutStateAsEmpty method.
	PutStateAsEmptyFunc func(ctx context.Context, filterJobID string) error

	// PutStateAsErrorFunc mocks the PutStateAsError method.
	PutStateAsErrorFunc func(ctx context.Context, filterJobID string) error
	// contains filtered or unexported fields
}

FilterStoreMock is a mock implementation of event.FilterStore.

func TestSomethingThatUsesFilterStore(t *testing.T) {

	// make and configure a mocked event.FilterStore
	mockedFilterStore := &FilterStoreMock{
		GetFilterFunc: func(ctx context.Context, filterID string) (*filter.Model, error) {
			panic("mock out the GetFilter method")
		},
		PutCSVDataFunc: func(ctx context.Context, filterID string, downloadItem filter.Download) error {
			panic("mock out the PutCSVData method")
		},
		PutStateAsEmptyFunc: func(ctx context.Context, filterJobID string) error {
			panic("mock out the PutStateAsEmpty method")
		},
		PutStateAsErrorFunc: func(ctx context.Context, filterJobID string) error {
			panic("mock out the PutStateAsError method")
		},
	}

	// use mockedFilterStore in code that requires event.FilterStore
	// and then make assertions.

}

func (*FilterStoreMock) GetFilter

func (mock *FilterStoreMock) GetFilter(ctx context.Context, filterID string) (*filter.Model, error)

GetFilter calls GetFilterFunc.

func (*FilterStoreMock) GetFilterCalls

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

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

len(mockedFilterStore.GetFilterCalls())

func (*FilterStoreMock) PutCSVData

func (mock *FilterStoreMock) PutCSVData(ctx context.Context, filterID string, downloadItem filter.Download) error

PutCSVData calls PutCSVDataFunc.

func (*FilterStoreMock) PutCSVDataCalls

func (mock *FilterStoreMock) PutCSVDataCalls() []struct {
	Ctx          context.Context
	FilterID     string
	DownloadItem filter.Download
}

PutCSVDataCalls gets all the calls that were made to PutCSVData. Check the length with:

len(mockedFilterStore.PutCSVDataCalls())

func (*FilterStoreMock) PutStateAsEmpty

func (mock *FilterStoreMock) PutStateAsEmpty(ctx context.Context, filterJobID string) error

PutStateAsEmpty calls PutStateAsEmptyFunc.

func (*FilterStoreMock) PutStateAsEmptyCalls

func (mock *FilterStoreMock) PutStateAsEmptyCalls() []struct {
	Ctx         context.Context
	FilterJobID string
}

PutStateAsEmptyCalls gets all the calls that were made to PutStateAsEmpty. Check the length with:

len(mockedFilterStore.PutStateAsEmptyCalls())

func (*FilterStoreMock) PutStateAsError

func (mock *FilterStoreMock) PutStateAsError(ctx context.Context, filterJobID string) error

PutStateAsError calls PutStateAsErrorFunc.

func (*FilterStoreMock) PutStateAsErrorCalls

func (mock *FilterStoreMock) PutStateAsErrorCalls() []struct {
	Ctx         context.Context
	FilterJobID string
}

PutStateAsErrorCalls gets all the calls that were made to PutStateAsError. Check the length with:

len(mockedFilterStore.PutStateAsErrorCalls())

type HandlerMock

type HandlerMock struct {
	// HandleFunc mocks the Handle method.
	HandleFunc func(ctx context.Context, cfg *config.Config, filterSubmitted *event.FilterSubmitted) error
	// contains filtered or unexported fields
}

HandlerMock is a mock implementation of event.Handler.

func TestSomethingThatUsesHandler(t *testing.T) {

	// make and configure a mocked event.Handler
	mockedHandler := &HandlerMock{
		HandleFunc: func(ctx context.Context, cfg *config.Config, filterSubmitted *event.FilterSubmitted) error {
			panic("mock out the Handle method")
		},
	}

	// use mockedHandler in code that requires event.Handler
	// and then make assertions.

}

func (*HandlerMock) Handle

func (mock *HandlerMock) Handle(ctx context.Context, cfg *config.Config, filterSubmitted *event.FilterSubmitted) error

Handle calls HandleFunc.

func (*HandlerMock) HandleCalls

func (mock *HandlerMock) HandleCalls() []struct {
	Ctx             context.Context
	Cfg             *config.Config
	FilterSubmitted *event.FilterSubmitted
}

HandleCalls gets all the calls that were made to Handle. Check the length with:

len(mockedHandler.HandleCalls())

type MarshallerMock

type MarshallerMock struct {
	// MarshalFunc mocks the Marshal method.
	MarshalFunc func(s interface{}) ([]byte, error)
	// contains filtered or unexported fields
}

MarshallerMock is a mock implementation of event.Marshaller.

func TestSomethingThatUsesMarshaller(t *testing.T) {

	// make and configure a mocked event.Marshaller
	mockedMarshaller := &MarshallerMock{
		MarshalFunc: func(s interface{}) ([]byte, error) {
			panic("mock out the Marshal method")
		},
	}

	// use mockedMarshaller in code that requires event.Marshaller
	// and then make assertions.

}

func (*MarshallerMock) Marshal

func (mock *MarshallerMock) Marshal(s interface{}) ([]byte, error)

Marshal calls MarshalFunc.

func (*MarshallerMock) MarshalCalls

func (mock *MarshallerMock) MarshalCalls() []struct {
	S interface{}
}

MarshalCalls gets all the calls that were made to Marshal. Check the length with:

len(mockedMarshaller.MarshalCalls())

type ObservationStoreMock

type ObservationStoreMock struct {
	// StreamCSVRowsFunc mocks the StreamCSVRows method.
	StreamCSVRowsFunc func(ctx context.Context, instanceID string, filterID string, filters *observation.DimensionFilters, limit *int) (observation.StreamRowReader, error)
	// contains filtered or unexported fields
}

ObservationStoreMock is a mock implementation of event.ObservationStore.

func TestSomethingThatUsesObservationStore(t *testing.T) {

	// make and configure a mocked event.ObservationStore
	mockedObservationStore := &ObservationStoreMock{
		StreamCSVRowsFunc: func(ctx context.Context, instanceID string, filterID string, filters *observation.DimensionFilters, limit *int) (observation.StreamRowReader, error) {
			panic("mock out the StreamCSVRows method")
		},
	}

	// use mockedObservationStore in code that requires event.ObservationStore
	// and then make assertions.

}

func (*ObservationStoreMock) StreamCSVRows

func (mock *ObservationStoreMock) StreamCSVRows(ctx context.Context, instanceID string, filterID string, filters *observation.DimensionFilters, limit *int) (observation.StreamRowReader, error)

StreamCSVRows calls StreamCSVRowsFunc.

func (*ObservationStoreMock) StreamCSVRowsCalls

func (mock *ObservationStoreMock) StreamCSVRowsCalls() []struct {
	Ctx        context.Context
	InstanceID string
	FilterID   string
	Filters    *observation.DimensionFilters
	Limit      *int
}

StreamCSVRowsCalls gets all the calls that were made to StreamCSVRows. Check the length with:

len(mockedObservationStore.StreamCSVRowsCalls())

type ProducerMock

type ProducerMock struct {
	// CSVExportedFunc mocks the CSVExported method.
	CSVExportedFunc func(ctx context.Context, e *event.CSVExported) error
	// contains filtered or unexported fields
}

ProducerMock is a mock implementation of event.Producer.

func TestSomethingThatUsesProducer(t *testing.T) {

	// make and configure a mocked event.Producer
	mockedProducer := &ProducerMock{
		CSVExportedFunc: func(ctx context.Context, e *event.CSVExported) error {
			panic("mock out the CSVExported method")
		},
	}

	// use mockedProducer in code that requires event.Producer
	// and then make assertions.

}

func (*ProducerMock) CSVExported

func (mock *ProducerMock) CSVExported(ctx context.Context, e *event.CSVExported) error

CSVExported calls CSVExportedFunc.

func (*ProducerMock) CSVExportedCalls

func (mock *ProducerMock) CSVExportedCalls() []struct {
	Ctx context.Context
	E   *event.CSVExported
}

CSVExportedCalls gets all the calls that were made to CSVExported. Check the length with:

len(mockedProducer.CSVExportedCalls())

Jump to

Keyboard shortcuts

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