mock

package
v0.17.0 Latest Latest
Warning

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

Go to latest
Published: Apr 8, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type AuthHandlerMock added in v0.9.0

type AuthHandlerMock struct {
	// RequireFunc mocks the Require method.
	RequireFunc func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc
	// contains filtered or unexported fields
}

AuthHandlerMock is a mock implementation of api.AuthHandler.

    func TestSomethingThatUsesAuthHandler(t *testing.T) {

        // make and configure a mocked api.AuthHandler
        mockedAuthHandler := &AuthHandlerMock{
            RequireFunc: func(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc {
	               panic("mock out the Require method")
            },
        }

        // use mockedAuthHandler in code that requires api.AuthHandler
        // and then make assertions.

    }

func (*AuthHandlerMock) Require added in v0.9.0

func (mock *AuthHandlerMock) Require(required auth.Permissions, handler http.HandlerFunc) http.HandlerFunc

Require calls RequireFunc.

func (*AuthHandlerMock) RequireCalls added in v0.9.0

func (mock *AuthHandlerMock) RequireCalls() []struct {
	Required auth.Permissions
	Handler  http.HandlerFunc
}

RequireCalls gets all the calls that were made to Require. Check the length with:

len(mockedAuthHandler.RequireCalls())

type DataStorerMock added in v0.11.0

type DataStorerMock struct {
	// AcquireJobLockFunc mocks the AcquireJobLock method.
	AcquireJobLockFunc func(ctx context.Context, id string) (string, error)

	// CreateJobFunc mocks the CreateJob method.
	CreateJobFunc func(ctx context.Context, id string) (models.Job, error)

	// CreateTaskFunc mocks the CreateTask method.
	CreateTaskFunc func(ctx context.Context, jobID string, taskName string, numDocuments int) (models.Task, error)

	// GetJobFunc mocks the GetJob method.
	GetJobFunc func(ctx context.Context, id string) (models.Job, error)

	// GetJobsFunc mocks the GetJobs method.
	GetJobsFunc func(ctx context.Context, offset int, limit int) (models.Jobs, error)

	// GetTaskFunc mocks the GetTask method.
	GetTaskFunc func(ctx context.Context, jobID string, taskName string) (models.Task, error)

	// GetTasksFunc mocks the GetTasks method.
	GetTasksFunc func(ctx context.Context, offset int, limit int, jobID string) (models.Tasks, error)

	// PutNumberOfTasksFunc mocks the PutNumberOfTasks method.
	PutNumberOfTasksFunc func(ctx context.Context, id string, count int) error

	// UnlockJobFunc mocks the UnlockJob method.
	UnlockJobFunc func(lockID string)

	// UpdateIndexNameFunc mocks the UpdateIndexName method.
	UpdateIndexNameFunc func(indexName string, jobID string) error

	// UpdateJobStateFunc mocks the UpdateJobState method.
	UpdateJobStateFunc func(state string, jobID string) error

	// UpdateJobWithPatchesFunc mocks the UpdateJobWithPatches method.
	UpdateJobWithPatchesFunc func(jobID string, updates bson.M) error
	// contains filtered or unexported fields
}

DataStorerMock is a mock implementation of api.DataStorer.

    func TestSomethingThatUsesDataStorer(t *testing.T) {

        // make and configure a mocked api.DataStorer
        mockedDataStorer := &DataStorerMock{
            AcquireJobLockFunc: func(ctx context.Context, id string) (string, error) {
	               panic("mock out the AcquireJobLock method")
            },
            CreateJobFunc: func(ctx context.Context, id string) (models.Job, error) {
	               panic("mock out the CreateJob method")
            },
            CreateTaskFunc: func(ctx context.Context, jobID string, taskName string, numDocuments int) (models.Task, error) {
	               panic("mock out the CreateTask method")
            },
            GetJobFunc: func(ctx context.Context, id string) (models.Job, error) {
	               panic("mock out the GetJob method")
            },
            GetJobsFunc: func(ctx context.Context, offset int, limit int) (models.Jobs, error) {
	               panic("mock out the GetJobs method")
            },
            GetTaskFunc: func(ctx context.Context, jobID string, taskName string) (models.Task, error) {
	               panic("mock out the GetTask method")
            },
            GetTasksFunc: func(ctx context.Context, offset int, limit int, jobID string) (models.Tasks, error) {
	               panic("mock out the GetTasks method")
            },
            PutNumberOfTasksFunc: func(ctx context.Context, id string, count int) error {
	               panic("mock out the PutNumberOfTasks method")
            },
            UnlockJobFunc: func(lockID string)  {
	               panic("mock out the UnlockJob method")
            },
            UpdateIndexNameFunc: func(indexName string, jobID string) error {
	               panic("mock out the UpdateIndexName method")
            },
            UpdateJobStateFunc: func(state string, jobID string) error {
	               panic("mock out the UpdateJobState method")
            },
            UpdateJobWithPatchesFunc: func(jobID string, updates bson.M) error {
	               panic("mock out the UpdateJobWithPatches method")
            },
        }

        // use mockedDataStorer in code that requires api.DataStorer
        // and then make assertions.

    }

func (*DataStorerMock) AcquireJobLock added in v0.11.0

func (mock *DataStorerMock) AcquireJobLock(ctx context.Context, id string) (string, error)

AcquireJobLock calls AcquireJobLockFunc.

func (*DataStorerMock) AcquireJobLockCalls added in v0.11.0

func (mock *DataStorerMock) AcquireJobLockCalls() []struct {
	Ctx context.Context
	ID  string
}

AcquireJobLockCalls gets all the calls that were made to AcquireJobLock. Check the length with:

len(mockedDataStorer.AcquireJobLockCalls())

func (*DataStorerMock) CreateJob added in v0.11.0

func (mock *DataStorerMock) CreateJob(ctx context.Context, id string) (models.Job, error)

CreateJob calls CreateJobFunc.

func (*DataStorerMock) CreateJobCalls added in v0.11.0

func (mock *DataStorerMock) CreateJobCalls() []struct {
	Ctx context.Context
	ID  string
}

CreateJobCalls gets all the calls that were made to CreateJob. Check the length with:

len(mockedDataStorer.CreateJobCalls())

func (*DataStorerMock) CreateTask added in v0.11.0

func (mock *DataStorerMock) CreateTask(ctx context.Context, jobID string, taskName string, numDocuments int) (models.Task, error)

CreateTask calls CreateTaskFunc.

func (*DataStorerMock) CreateTaskCalls added in v0.11.0

func (mock *DataStorerMock) CreateTaskCalls() []struct {
	Ctx          context.Context
	JobID        string
	TaskName     string
	NumDocuments int
}

CreateTaskCalls gets all the calls that were made to CreateTask. Check the length with:

len(mockedDataStorer.CreateTaskCalls())

func (*DataStorerMock) GetJob added in v0.11.0

func (mock *DataStorerMock) GetJob(ctx context.Context, id string) (models.Job, error)

GetJob calls GetJobFunc.

func (*DataStorerMock) GetJobCalls added in v0.11.0

func (mock *DataStorerMock) GetJobCalls() []struct {
	Ctx context.Context
	ID  string
}

GetJobCalls gets all the calls that were made to GetJob. Check the length with:

len(mockedDataStorer.GetJobCalls())

func (*DataStorerMock) GetJobs added in v0.11.0

func (mock *DataStorerMock) GetJobs(ctx context.Context, offset int, limit int) (models.Jobs, error)

GetJobs calls GetJobsFunc.

func (*DataStorerMock) GetJobsCalls added in v0.11.0

func (mock *DataStorerMock) GetJobsCalls() []struct {
	Ctx    context.Context
	Offset int
	Limit  int
}

GetJobsCalls gets all the calls that were made to GetJobs. Check the length with:

len(mockedDataStorer.GetJobsCalls())

func (*DataStorerMock) GetTask added in v0.11.0

func (mock *DataStorerMock) GetTask(ctx context.Context, jobID string, taskName string) (models.Task, error)

GetTask calls GetTaskFunc.

func (*DataStorerMock) GetTaskCalls added in v0.11.0

func (mock *DataStorerMock) GetTaskCalls() []struct {
	Ctx      context.Context
	JobID    string
	TaskName string
}

GetTaskCalls gets all the calls that were made to GetTask. Check the length with:

len(mockedDataStorer.GetTaskCalls())

func (*DataStorerMock) GetTasks added in v0.12.0

func (mock *DataStorerMock) GetTasks(ctx context.Context, offset int, limit int, jobID string) (models.Tasks, error)

GetTasks calls GetTasksFunc.

func (*DataStorerMock) GetTasksCalls added in v0.12.0

func (mock *DataStorerMock) GetTasksCalls() []struct {
	Ctx    context.Context
	Offset int
	Limit  int
	JobID  string
}

GetTasksCalls gets all the calls that were made to GetTasks. Check the length with:

len(mockedDataStorer.GetTasksCalls())

func (*DataStorerMock) PutNumberOfTasks added in v0.11.0

func (mock *DataStorerMock) PutNumberOfTasks(ctx context.Context, id string, count int) error

PutNumberOfTasks calls PutNumberOfTasksFunc.

func (*DataStorerMock) PutNumberOfTasksCalls added in v0.11.0

func (mock *DataStorerMock) PutNumberOfTasksCalls() []struct {
	Ctx   context.Context
	ID    string
	Count int
}

PutNumberOfTasksCalls gets all the calls that were made to PutNumberOfTasks. Check the length with:

len(mockedDataStorer.PutNumberOfTasksCalls())

func (*DataStorerMock) UnlockJob added in v0.11.0

func (mock *DataStorerMock) UnlockJob(lockID string)

UnlockJob calls UnlockJobFunc.

func (*DataStorerMock) UnlockJobCalls added in v0.11.0

func (mock *DataStorerMock) UnlockJobCalls() []struct {
	LockID string
}

UnlockJobCalls gets all the calls that were made to UnlockJob. Check the length with:

len(mockedDataStorer.UnlockJobCalls())

func (*DataStorerMock) UpdateIndexName added in v0.14.0

func (mock *DataStorerMock) UpdateIndexName(indexName string, jobID string) error

UpdateIndexName calls UpdateIndexNameFunc.

func (*DataStorerMock) UpdateIndexNameCalls added in v0.14.0

func (mock *DataStorerMock) UpdateIndexNameCalls() []struct {
	IndexName string
	JobID     string
}

UpdateIndexNameCalls gets all the calls that were made to UpdateIndexName. Check the length with:

len(mockedDataStorer.UpdateIndexNameCalls())

func (*DataStorerMock) UpdateJobState added in v0.14.0

func (mock *DataStorerMock) UpdateJobState(state string, jobID string) error

UpdateJobState calls UpdateJobStateFunc.

func (*DataStorerMock) UpdateJobStateCalls added in v0.14.0

func (mock *DataStorerMock) UpdateJobStateCalls() []struct {
	State string
	JobID string
}

UpdateJobStateCalls gets all the calls that were made to UpdateJobState. Check the length with:

len(mockedDataStorer.UpdateJobStateCalls())

func (*DataStorerMock) UpdateJobWithPatches added in v0.16.0

func (mock *DataStorerMock) UpdateJobWithPatches(jobID string, updates bson.M) error

UpdateJobWithPatches calls UpdateJobWithPatchesFunc.

func (*DataStorerMock) UpdateJobWithPatchesCalls added in v0.16.0

func (mock *DataStorerMock) UpdateJobWithPatchesCalls() []struct {
	JobID   string
	Updates bson.M
}

UpdateJobWithPatchesCalls gets all the calls that were made to UpdateJobWithPatches. Check the length with:

len(mockedDataStorer.UpdateJobWithPatchesCalls())

type IndexerMock added in v0.14.0

type IndexerMock struct {
	// CreateIndexFunc mocks the CreateIndex method.
	CreateIndexFunc func(ctx context.Context, serviceAuthToken string, searchAPISearchURL string, httpClient dpHTTP.Clienter) (*http.Response, error)

	// GetIndexNameFromResponseFunc mocks the GetIndexNameFromResponse method.
	GetIndexNameFromResponseFunc func(ctx context.Context, body io.ReadCloser) (string, error)

	// SendReindexRequestedEventFunc mocks the SendReindexRequestedEvent method.
	SendReindexRequestedEventFunc func(cfg *config.Config, jobID string, indexName string) error
	// contains filtered or unexported fields
}

IndexerMock is a mock implementation of api.Indexer.

func TestSomethingThatUsesIndexer(t *testing.T) {

	// make and configure a mocked api.Indexer
	mockedIndexer := &IndexerMock{
		CreateIndexFunc: func(ctx context.Context, serviceAuthToken string, searchAPISearchURL string, httpClient dpHTTP.Clienter) (*http.Response, error) {
			panic("mock out the CreateIndex method")
		},
		GetIndexNameFromResponseFunc: func(ctx context.Context, body io.ReadCloser) (string, error) {
			panic("mock out the GetIndexNameFromResponse method")
		},
		SendReindexRequestedEventFunc: func(cfg *config.Config, jobID string, indexName string) error {
			panic("mock out the SendReindexRequestedEvent method")
		},
	}

	// use mockedIndexer in code that requires api.Indexer
	// and then make assertions.

}

func (*IndexerMock) CreateIndex added in v0.14.0

func (mock *IndexerMock) CreateIndex(ctx context.Context, serviceAuthToken string, searchAPISearchURL string, httpClient dpHTTP.Clienter) (*http.Response, error)

CreateIndex calls CreateIndexFunc.

func (*IndexerMock) CreateIndexCalls added in v0.14.0

func (mock *IndexerMock) CreateIndexCalls() []struct {
	Ctx                context.Context
	ServiceAuthToken   string
	SearchAPISearchURL string
	HttpClient         dpHTTP.Clienter
}

CreateIndexCalls gets all the calls that were made to CreateIndex. Check the length with:

len(mockedIndexer.CreateIndexCalls())

func (*IndexerMock) GetIndexNameFromResponse added in v0.14.0

func (mock *IndexerMock) GetIndexNameFromResponse(ctx context.Context, body io.ReadCloser) (string, error)

GetIndexNameFromResponse calls GetIndexNameFromResponseFunc.

func (*IndexerMock) GetIndexNameFromResponseCalls added in v0.14.0

func (mock *IndexerMock) GetIndexNameFromResponseCalls() []struct {
	Ctx  context.Context
	Body io.ReadCloser
}

GetIndexNameFromResponseCalls gets all the calls that were made to GetIndexNameFromResponse. Check the length with:

len(mockedIndexer.GetIndexNameFromResponseCalls())

func (*IndexerMock) SendReindexRequestedEvent added in v0.15.0

func (mock *IndexerMock) SendReindexRequestedEvent(cfg *config.Config, jobID string, indexName string) error

SendReindexRequestedEvent calls SendReindexRequestedEventFunc.

func (*IndexerMock) SendReindexRequestedEventCalls added in v0.15.0

func (mock *IndexerMock) SendReindexRequestedEventCalls() []struct {
	Cfg       *config.Config
	JobID     string
	IndexName string
}

SendReindexRequestedEventCalls gets all the calls that were made to SendReindexRequestedEvent. Check the length with:

len(mockedIndexer.SendReindexRequestedEventCalls())

type ReindexRequestedProducerMock added in v0.15.0

type ReindexRequestedProducerMock struct {
	// ProduceReindexRequestedFunc mocks the ProduceReindexRequested method.
	ProduceReindexRequestedFunc func(ctx context.Context, event models.ReindexRequested) error
	// contains filtered or unexported fields
}

ReindexRequestedProducerMock is a mock implementation of api.ReindexRequestedProducer.

func TestSomethingThatUsesReindexRequestedProducer(t *testing.T) {

	// make and configure a mocked api.ReindexRequestedProducer
	mockedReindexRequestedProducer := &ReindexRequestedProducerMock{
		ProduceReindexRequestedFunc: func(ctx context.Context, event models.ReindexRequested) error {
			panic("mock out the ProduceReindexRequested method")
		},
	}

	// use mockedReindexRequestedProducer in code that requires api.ReindexRequestedProducer
	// and then make assertions.

}

func (*ReindexRequestedProducerMock) ProduceReindexRequested added in v0.15.0

func (mock *ReindexRequestedProducerMock) ProduceReindexRequested(ctx context.Context, event models.ReindexRequested) error

ProduceReindexRequested calls ProduceReindexRequestedFunc.

func (*ReindexRequestedProducerMock) ProduceReindexRequestedCalls added in v0.15.0

func (mock *ReindexRequestedProducerMock) ProduceReindexRequestedCalls() []struct {
	Ctx   context.Context
	Event models.ReindexRequested
}

ProduceReindexRequestedCalls gets all the calls that were made to ProduceReindexRequested. Check the length with:

len(mockedReindexRequestedProducer.ProduceReindexRequestedCalls())

Jump to

Keyboard shortcuts

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