mock

package
v0.12.0 Latest Latest
Warning

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

Go to latest
Published: Nov 16, 2021 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 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, offsetParam string, limitParam string) (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) 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, offsetParam string, limitParam string) (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) error {
			panic("mock out the UnlockJob 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, offsetParam string, limitParam string) (models.Jobs, error)

GetJobs calls GetJobsFunc.

func (*DataStorerMock) GetJobsCalls added in v0.11.0

func (mock *DataStorerMock) GetJobsCalls() []struct {
	Ctx         context.Context
	OffsetParam string
	LimitParam  string
}

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

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

Jump to

Keyboard shortcuts

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