mock

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2025 License: MIT Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type JobServiceMock

type JobServiceMock struct {
	// CreateJobFunc mocks the CreateJob method.
	CreateJobFunc func(ctx context.Context, jobConfig *domain.JobConfig) (*domain.Job, error)

	// GetJobFunc mocks the GetJob method.
	GetJobFunc func(ctx context.Context, jobID string) (*domain.Job, error)

	// GetJobsFunc mocks the GetJobs method.
	GetJobsFunc func(ctx context.Context, limit int, offset int) ([]*domain.Job, int, error)
	// contains filtered or unexported fields
}

JobServiceMock is a mock implementation of application.JobService.

func TestSomethingThatUsesJobService(t *testing.T) {

	// make and configure a mocked application.JobService
	mockedJobService := &JobServiceMock{
		CreateJobFunc: func(ctx context.Context, jobConfig *domain.JobConfig) (*domain.Job, error) {
			panic("mock out the CreateJob method")
		},
		GetJobFunc: func(ctx context.Context, jobID string) (*domain.Job, error) {
			panic("mock out the GetJob method")
		},
		GetJobsFunc: func(ctx context.Context, limit int, offset int) ([]*domain.Job, int, error) {
			panic("mock out the GetJobs method")
		},
	}

	// use mockedJobService in code that requires application.JobService
	// and then make assertions.

}

func (*JobServiceMock) CreateJob

func (mock *JobServiceMock) CreateJob(ctx context.Context, jobConfig *domain.JobConfig) (*domain.Job, error)

CreateJob calls CreateJobFunc.

func (*JobServiceMock) CreateJobCalls

func (mock *JobServiceMock) CreateJobCalls() []struct {
	Ctx       context.Context
	JobConfig *domain.JobConfig
}

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

len(mockedJobService.CreateJobCalls())

func (*JobServiceMock) GetJob

func (mock *JobServiceMock) GetJob(ctx context.Context, jobID string) (*domain.Job, error)

GetJob calls GetJobFunc.

func (*JobServiceMock) GetJobCalls

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

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

len(mockedJobService.GetJobCalls())

func (*JobServiceMock) GetJobs added in v0.10.0

func (mock *JobServiceMock) GetJobs(ctx context.Context, limit int, offset int) ([]*domain.Job, int, error)

GetJobs calls GetJobsFunc.

func (*JobServiceMock) GetJobsCalls added in v0.10.0

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

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

len(mockedJobService.GetJobsCalls())

Jump to

Keyboard shortcuts

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