mock

package
v1.19.0 Latest Latest
Warning

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

Go to latest
Published: Jun 28, 2024 License: MIT Imports: 5 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 {
	// GetMetadataURLFunc mocks the GetMetadataURL method.
	GetMetadataURLFunc func(id string, edition string, version string) string

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

	// GetVersionMetadataSelectionFunc mocks the GetVersionMetadataSelection method.
	GetVersionMetadataSelectionFunc func(ctx context.Context, req dataset.GetVersionMetadataSelectionInput) (*dataset.Metadata, error)

	// PutVersionFunc mocks the PutVersion method.
	PutVersionFunc func(ctx context.Context, usrAuthToken string, svcAuthToken string, collectionID string, datasetID string, edition string, ver string, v dataset.Version) error
	// contains filtered or unexported fields
}

DatasetAPIClientMock is a mock implementation of handler.DatasetAPIClient.

func TestSomethingThatUsesDatasetAPIClient(t *testing.T) {

	// make and configure a mocked handler.DatasetAPIClient
	mockedDatasetAPIClient := &DatasetAPIClientMock{
		GetMetadataURLFunc: func(id string, edition string, version string) string {
			panic("mock out the GetMetadataURL 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")
		},
		GetVersionMetadataSelectionFunc: func(ctx context.Context, req dataset.GetVersionMetadataSelectionInput) (*dataset.Metadata, error) {
			panic("mock out the GetVersionMetadataSelection method")
		},
		PutVersionFunc: func(ctx context.Context, usrAuthToken string, svcAuthToken string, collectionID string, datasetID string, edition string, ver string, v dataset.Version) error {
			panic("mock out the PutVersion method")
		},
	}

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

}

func (*DatasetAPIClientMock) GetMetadataURL

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

GetMetadataURL calls GetMetadataURLFunc.

func (*DatasetAPIClientMock) GetMetadataURLCalls

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

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

len(mockedDatasetAPIClient.GetMetadataURLCalls())

func (*DatasetAPIClientMock) GetOptionsInBatches

func (mock *DatasetAPIClientMock) 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 (*DatasetAPIClientMock) GetOptionsInBatchesCalls

func (mock *DatasetAPIClientMock) 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(mockedDatasetAPIClient.GetOptionsInBatchesCalls())

func (*DatasetAPIClientMock) GetVersion

func (mock *DatasetAPIClientMock) 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 (*DatasetAPIClientMock) GetVersionCalls

func (mock *DatasetAPIClientMock) 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(mockedDatasetAPIClient.GetVersionCalls())

func (*DatasetAPIClientMock) GetVersionDimensions

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

GetVersionDimensions calls GetVersionDimensionsFunc.

func (*DatasetAPIClientMock) GetVersionDimensionsCalls

func (mock *DatasetAPIClientMock) 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(mockedDatasetAPIClient.GetVersionDimensionsCalls())

func (*DatasetAPIClientMock) GetVersionMetadata

func (mock *DatasetAPIClientMock) GetVersionMetadata(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, id string, edition string, version string) (dataset.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())

func (*DatasetAPIClientMock) GetVersionMetadataSelection added in v1.3.0

func (mock *DatasetAPIClientMock) GetVersionMetadataSelection(ctx context.Context, req dataset.GetVersionMetadataSelectionInput) (*dataset.Metadata, error)

GetVersionMetadataSelection calls GetVersionMetadataSelectionFunc.

func (*DatasetAPIClientMock) GetVersionMetadataSelectionCalls added in v1.3.0

func (mock *DatasetAPIClientMock) GetVersionMetadataSelectionCalls() []struct {
	Ctx context.Context
	Req dataset.GetVersionMetadataSelectionInput
}

GetVersionMetadataSelectionCalls gets all the calls that were made to GetVersionMetadataSelection. Check the length with:

len(mockedDatasetAPIClient.GetVersionMetadataSelectionCalls())

func (*DatasetAPIClientMock) PutVersion

func (mock *DatasetAPIClientMock) PutVersion(ctx context.Context, usrAuthToken string, svcAuthToken string, collectionID string, datasetID string, edition string, ver string, v dataset.Version) error

PutVersion calls PutVersionFunc.

func (*DatasetAPIClientMock) PutVersionCalls

func (mock *DatasetAPIClientMock) PutVersionCalls() []struct {
	Ctx          context.Context
	UsrAuthToken string
	SvcAuthToken string
	CollectionID string
	DatasetID    string
	Edition      string
	Ver          string
	V            dataset.Version
}

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

len(mockedDatasetAPIClient.PutVersionCalls())

type FileManagerMock

type FileManagerMock struct {
	// UploadFunc mocks the Upload method.
	UploadFunc func(body io.Reader, filename string) (string, error)

	// UploadPrivateFunc mocks the UploadPrivate method.
	UploadPrivateFunc func(body io.Reader, filename string, vaultPath string) (string, error)
	// contains filtered or unexported fields
}

FileManagerMock is a mock implementation of handler.FileManager.

func TestSomethingThatUsesFileManager(t *testing.T) {

	// make and configure a mocked handler.FileManager
	mockedFileManager := &FileManagerMock{
		UploadFunc: func(body io.Reader, filename string) (string, error) {
			panic("mock out the Upload method")
		},
		UploadPrivateFunc: func(body io.Reader, filename string, vaultPath string) (string, error) {
			panic("mock out the UploadPrivate method")
		},
	}

	// use mockedFileManager in code that requires handler.FileManager
	// and then make assertions.

}

func (*FileManagerMock) Upload

func (mock *FileManagerMock) Upload(body io.Reader, filename string) (string, error)

Upload calls UploadFunc.

func (*FileManagerMock) UploadCalls

func (mock *FileManagerMock) UploadCalls() []struct {
	Body     io.Reader
	Filename string
}

UploadCalls gets all the calls that were made to Upload. Check the length with:

len(mockedFileManager.UploadCalls())

func (*FileManagerMock) UploadPrivate

func (mock *FileManagerMock) UploadPrivate(body io.Reader, filename string, vaultPath string) (string, error)

UploadPrivate calls UploadPrivateFunc.

func (*FileManagerMock) UploadPrivateCalls

func (mock *FileManagerMock) UploadPrivateCalls() []struct {
	Body      io.Reader
	Filename  string
	VaultPath string
}

UploadPrivateCalls gets all the calls that were made to UploadPrivate. Check the length with:

len(mockedFileManager.UploadPrivateCalls())

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL
JackTT - Gopher 🇻🇳