mock

package
v0.14.0 Latest Latest
Warning

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

Go to latest
Published: Dec 3, 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 {
	// CountEventsByJobIDFunc mocks the CountEventsByJobID method.
	CountEventsByJobIDFunc func(ctx context.Context, jobID string) (int, error)

	// CountTasksByJobIDFunc mocks the CountTasksByJobID method.
	CountTasksByJobIDFunc func(ctx context.Context, jobID string) (int, error)

	// CreateEventFunc mocks the CreateEvent method.
	CreateEventFunc func(ctx context.Context, jobID string, event *domain.Event) (*domain.Event, error)

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

	// CreateTaskFunc mocks the CreateTask method.
	CreateTaskFunc func(ctx context.Context, jobID string, task *domain.Task) (*domain.Task, error)

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

	// GetJobEventsFunc mocks the GetJobEvents method.
	GetJobEventsFunc func(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Event, int, error)

	// GetJobTasksFunc mocks the GetJobTasks method.
	GetJobTasksFunc func(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Task, int, error)

	// GetJobsFunc mocks the GetJobs method.
	GetJobsFunc func(ctx context.Context, states []domain.JobState, 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{
		CountEventsByJobIDFunc: func(ctx context.Context, jobID string) (int, error) {
			panic("mock out the CountEventsByJobID method")
		},
		CountTasksByJobIDFunc: func(ctx context.Context, jobID string) (int, error) {
			panic("mock out the CountTasksByJobID method")
		},
		CreateEventFunc: func(ctx context.Context, jobID string, event *domain.Event) (*domain.Event, error) {
			panic("mock out the CreateEvent method")
		},
		CreateJobFunc: func(ctx context.Context, jobConfig *domain.JobConfig) (*domain.Job, error) {
			panic("mock out the CreateJob method")
		},
		CreateTaskFunc: func(ctx context.Context, jobID string, task *domain.Task) (*domain.Task, error) {
			panic("mock out the CreateTask method")
		},
		GetJobFunc: func(ctx context.Context, jobID string) (*domain.Job, error) {
			panic("mock out the GetJob method")
		},
		GetJobEventsFunc: func(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Event, int, error) {
			panic("mock out the GetJobEvents method")
		},
		GetJobTasksFunc: func(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Task, int, error) {
			panic("mock out the GetJobTasks method")
		},
		GetJobsFunc: func(ctx context.Context, states []domain.JobState, 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) CountEventsByJobID added in v0.12.0

func (mock *JobServiceMock) CountEventsByJobID(ctx context.Context, jobID string) (int, error)

CountEventsByJobID calls CountEventsByJobIDFunc.

func (*JobServiceMock) CountEventsByJobIDCalls added in v0.12.0

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

CountEventsByJobIDCalls gets all the calls that were made to CountEventsByJobID. Check the length with:

len(mockedJobService.CountEventsByJobIDCalls())

func (*JobServiceMock) CountTasksByJobID added in v0.11.0

func (mock *JobServiceMock) CountTasksByJobID(ctx context.Context, jobID string) (int, error)

CountTasksByJobID calls CountTasksByJobIDFunc.

func (*JobServiceMock) CountTasksByJobIDCalls added in v0.11.0

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

CountTasksByJobIDCalls gets all the calls that were made to CountTasksByJobID. Check the length with:

len(mockedJobService.CountTasksByJobIDCalls())

func (*JobServiceMock) CreateEvent added in v0.12.0

func (mock *JobServiceMock) CreateEvent(ctx context.Context, jobID string, event *domain.Event) (*domain.Event, error)

CreateEvent calls CreateEventFunc.

func (*JobServiceMock) CreateEventCalls added in v0.12.0

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

CreateEventCalls gets all the calls that were made to CreateEvent. Check the length with:

len(mockedJobService.CreateEventCalls())

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) CreateTask added in v0.12.0

func (mock *JobServiceMock) CreateTask(ctx context.Context, jobID string, task *domain.Task) (*domain.Task, error)

CreateTask calls CreateTaskFunc.

func (*JobServiceMock) CreateTaskCalls added in v0.12.0

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

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

len(mockedJobService.CreateTaskCalls())

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) GetJobEvents added in v0.12.0

func (mock *JobServiceMock) GetJobEvents(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Event, int, error)

GetJobEvents calls GetJobEventsFunc.

func (*JobServiceMock) GetJobEventsCalls added in v0.12.0

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

GetJobEventsCalls gets all the calls that were made to GetJobEvents. Check the length with:

len(mockedJobService.GetJobEventsCalls())

func (*JobServiceMock) GetJobTasks added in v0.11.0

func (mock *JobServiceMock) GetJobTasks(ctx context.Context, jobID string, limit int, offset int) ([]*domain.Task, int, error)

GetJobTasks calls GetJobTasksFunc.

func (*JobServiceMock) GetJobTasksCalls added in v0.11.0

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

GetJobTasksCalls gets all the calls that were made to GetJobTasks. Check the length with:

len(mockedJobService.GetJobTasksCalls())

func (*JobServiceMock) GetJobs added in v0.10.0

func (mock *JobServiceMock) GetJobs(ctx context.Context, states []domain.JobState, 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
	States []domain.JobState
	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