mock

package
v0.9.0 Latest Latest
Warning

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

Go to latest
Published: Nov 21, 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)
	// 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")
		},
	}

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

Jump to

Keyboard shortcuts

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