mock

package
v1.21.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2024 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 DatasetClientMock

type DatasetClientMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, check *healthcheck.CheckState) error

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

	// GetInstancesInBatchesFunc mocks the GetInstancesInBatches method.
	GetInstancesInBatchesFunc func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, vars url.Values, batchSize int, maxWorkers int) (dataset.Instances, error)

	// PutInstanceImportTasksFunc mocks the PutInstanceImportTasks method.
	PutInstanceImportTasksFunc func(ctx context.Context, serviceAuthToken string, instanceID string, data dataset.InstanceImportTasks, ifMatch string) (string, error)

	// PutInstanceStateFunc mocks the PutInstanceState method.
	PutInstanceStateFunc func(ctx context.Context, serviceAuthToken string, instanceID string, state dataset.State, ifMatch string) (string, error)

	// UpdateInstanceWithNewInsertsFunc mocks the UpdateInstanceWithNewInserts method.
	UpdateInstanceWithNewInsertsFunc func(ctx context.Context, serviceAuthToken string, instanceID string, observationsInserted int32, ifMatch string) (string, error)
	// contains filtered or unexported fields
}

DatasetClientMock is a mock implementation of api.DatasetClient.

func TestSomethingThatUsesDatasetClient(t *testing.T) {

	// make and configure a mocked api.DatasetClient
	mockedDatasetClient := &DatasetClientMock{
		CheckerFunc: func(ctx context.Context, check *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		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")
		},
		GetInstancesInBatchesFunc: func(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, vars url.Values, batchSize int, maxWorkers int) (dataset.Instances, error) {
			panic("mock out the GetInstancesInBatches method")
		},
		PutInstanceImportTasksFunc: func(ctx context.Context, serviceAuthToken string, instanceID string, data dataset.InstanceImportTasks, ifMatch string) (string, error) {
			panic("mock out the PutInstanceImportTasks method")
		},
		PutInstanceStateFunc: func(ctx context.Context, serviceAuthToken string, instanceID string, state dataset.State, ifMatch string) (string, error) {
			panic("mock out the PutInstanceState method")
		},
		UpdateInstanceWithNewInsertsFunc: func(ctx context.Context, serviceAuthToken string, instanceID string, observationsInserted int32, ifMatch string) (string, error) {
			panic("mock out the UpdateInstanceWithNewInserts method")
		},
	}

	// use mockedDatasetClient in code that requires api.DatasetClient
	// and then make assertions.

}

func (*DatasetClientMock) Checker

func (mock *DatasetClientMock) Checker(ctx context.Context, check *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*DatasetClientMock) CheckerCalls

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

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

len(mockedDatasetClient.CheckerCalls())

func (*DatasetClientMock) GetInstance

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

GetInstance calls GetInstanceFunc.

func (*DatasetClientMock) GetInstanceCalls

func (mock *DatasetClientMock) 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(mockedDatasetClient.GetInstanceCalls())

func (*DatasetClientMock) GetInstancesInBatches added in v1.13.0

func (mock *DatasetClientMock) GetInstancesInBatches(ctx context.Context, userAuthToken string, serviceAuthToken string, collectionID string, vars url.Values, batchSize int, maxWorkers int) (dataset.Instances, error)

GetInstancesInBatches calls GetInstancesInBatchesFunc.

func (*DatasetClientMock) GetInstancesInBatchesCalls added in v1.13.0

func (mock *DatasetClientMock) GetInstancesInBatchesCalls() []struct {
	Ctx              context.Context
	UserAuthToken    string
	ServiceAuthToken string
	CollectionID     string
	Vars             url.Values
	BatchSize        int
	MaxWorkers       int
}

GetInstancesInBatchesCalls gets all the calls that were made to GetInstancesInBatches. Check the length with:

len(mockedDatasetClient.GetInstancesInBatchesCalls())

func (*DatasetClientMock) PutInstanceImportTasks

func (mock *DatasetClientMock) PutInstanceImportTasks(ctx context.Context, serviceAuthToken string, instanceID string, data dataset.InstanceImportTasks, ifMatch string) (string, error)

PutInstanceImportTasks calls PutInstanceImportTasksFunc.

func (*DatasetClientMock) PutInstanceImportTasksCalls

func (mock *DatasetClientMock) PutInstanceImportTasksCalls() []struct {
	Ctx              context.Context
	ServiceAuthToken string
	InstanceID       string
	Data             dataset.InstanceImportTasks
	IfMatch          string
}

PutInstanceImportTasksCalls gets all the calls that were made to PutInstanceImportTasks. Check the length with:

len(mockedDatasetClient.PutInstanceImportTasksCalls())

func (*DatasetClientMock) PutInstanceState

func (mock *DatasetClientMock) PutInstanceState(ctx context.Context, serviceAuthToken string, instanceID string, state dataset.State, ifMatch string) (string, error)

PutInstanceState calls PutInstanceStateFunc.

func (*DatasetClientMock) PutInstanceStateCalls

func (mock *DatasetClientMock) PutInstanceStateCalls() []struct {
	Ctx              context.Context
	ServiceAuthToken string
	InstanceID       string
	State            dataset.State
	IfMatch          string
}

PutInstanceStateCalls gets all the calls that were made to PutInstanceState. Check the length with:

len(mockedDatasetClient.PutInstanceStateCalls())

func (*DatasetClientMock) UpdateInstanceWithNewInserts

func (mock *DatasetClientMock) UpdateInstanceWithNewInserts(ctx context.Context, serviceAuthToken string, instanceID string, observationsInserted int32, ifMatch string) (string, error)

UpdateInstanceWithNewInserts calls UpdateInstanceWithNewInsertsFunc.

func (*DatasetClientMock) UpdateInstanceWithNewInsertsCalls

func (mock *DatasetClientMock) UpdateInstanceWithNewInsertsCalls() []struct {
	Ctx                  context.Context
	ServiceAuthToken     string
	InstanceID           string
	ObservationsInserted int32
	IfMatch              string
}

UpdateInstanceWithNewInsertsCalls gets all the calls that were made to UpdateInstanceWithNewInserts. Check the length with:

len(mockedDatasetClient.UpdateInstanceWithNewInsertsCalls())

type ImportAPIClientMock

type ImportAPIClientMock struct {
	// CheckerFunc mocks the Checker method.
	CheckerFunc func(ctx context.Context, check *healthcheck.CheckState) error

	// GetImportJobFunc mocks the GetImportJob method.
	GetImportJobFunc func(ctx context.Context, importJobID string, serviceToken string) (importapi.ImportJob, error)

	// UpdateImportJobStateFunc mocks the UpdateImportJobState method.
	UpdateImportJobStateFunc func(ctx context.Context, jobID string, serviceToken string, newState importapi.State) error
	// contains filtered or unexported fields
}

ImportAPIClientMock is a mock implementation of api.ImportAPIClient.

func TestSomethingThatUsesImportAPIClient(t *testing.T) {

	// make and configure a mocked api.ImportAPIClient
	mockedImportAPIClient := &ImportAPIClientMock{
		CheckerFunc: func(ctx context.Context, check *healthcheck.CheckState) error {
			panic("mock out the Checker method")
		},
		GetImportJobFunc: func(ctx context.Context, importJobID string, serviceToken string) (importapi.ImportJob, error) {
			panic("mock out the GetImportJob method")
		},
		UpdateImportJobStateFunc: func(ctx context.Context, jobID string, serviceToken string, newState importapi.State) error {
			panic("mock out the UpdateImportJobState method")
		},
	}

	// use mockedImportAPIClient in code that requires api.ImportAPIClient
	// and then make assertions.

}

func (*ImportAPIClientMock) Checker

func (mock *ImportAPIClientMock) Checker(ctx context.Context, check *healthcheck.CheckState) error

Checker calls CheckerFunc.

func (*ImportAPIClientMock) CheckerCalls

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

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

len(mockedImportAPIClient.CheckerCalls())

func (*ImportAPIClientMock) GetImportJob

func (mock *ImportAPIClientMock) GetImportJob(ctx context.Context, importJobID string, serviceToken string) (importapi.ImportJob, error)

GetImportJob calls GetImportJobFunc.

func (*ImportAPIClientMock) GetImportJobCalls

func (mock *ImportAPIClientMock) GetImportJobCalls() []struct {
	Ctx          context.Context
	ImportJobID  string
	ServiceToken string
}

GetImportJobCalls gets all the calls that were made to GetImportJob. Check the length with:

len(mockedImportAPIClient.GetImportJobCalls())

func (*ImportAPIClientMock) UpdateImportJobState

func (mock *ImportAPIClientMock) UpdateImportJobState(ctx context.Context, jobID string, serviceToken string, newState importapi.State) error

UpdateImportJobState calls UpdateImportJobStateFunc.

func (*ImportAPIClientMock) UpdateImportJobStateCalls

func (mock *ImportAPIClientMock) UpdateImportJobStateCalls() []struct {
	Ctx          context.Context
	JobID        string
	ServiceToken string
	NewState     importapi.State
}

UpdateImportJobStateCalls gets all the calls that were made to UpdateImportJobState. Check the length with:

len(mockedImportAPIClient.UpdateImportJobStateCalls())

Jump to

Keyboard shortcuts

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