mock

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Jan 4, 2024 License: MIT Imports: 3 Imported by: 1

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type QorJobInterfaceMock

type QorJobInterfaceMock struct {
	// AddLogFunc mocks the AddLog method.
	AddLogFunc func(s string) error

	// AddLogfFunc mocks the AddLogf method.
	AddLogfFunc func(format string, a ...interface{}) error

	// GetJobInfoFunc mocks the GetJobInfo method.
	GetJobInfoFunc func() (*worker.JobInfo, error)

	// SetProgressFunc mocks the SetProgress method.
	SetProgressFunc func(v uint) error

	// SetProgressTextFunc mocks the SetProgressText method.
	SetProgressTextFunc func(s string) error
	// contains filtered or unexported fields
}

QorJobInterfaceMock is a mock implementation of worker.QorJobInterface.

func TestSomethingThatUsesQorJobInterface(t *testing.T) {

	// make and configure a mocked worker.QorJobInterface
	mockedQorJobInterface := &QorJobInterfaceMock{
		AddLogFunc: func(s string) error {
			panic("mock out the AddLog method")
		},
		AddLogfFunc: func(format string, a ...interface{}) error {
			panic("mock out the AddLogf method")
		},
		GetJobInfoFunc: func() (*worker.JobInfo, error) {
			panic("mock out the GetJobInfo method")
		},
		SetProgressFunc: func(v uint) error {
			panic("mock out the SetProgress method")
		},
		SetProgressTextFunc: func(s string) error {
			panic("mock out the SetProgressText method")
		},
	}

	// use mockedQorJobInterface in code that requires worker.QorJobInterface
	// and then make assertions.

}

func (*QorJobInterfaceMock) AddLog

func (mock *QorJobInterfaceMock) AddLog(s string) error

AddLog calls AddLogFunc.

func (*QorJobInterfaceMock) AddLogCalls

func (mock *QorJobInterfaceMock) AddLogCalls() []struct {
	S string
}

AddLogCalls gets all the calls that were made to AddLog. Check the length with:

len(mockedQorJobInterface.AddLogCalls())

func (*QorJobInterfaceMock) AddLogf

func (mock *QorJobInterfaceMock) AddLogf(format string, a ...interface{}) error

AddLogf calls AddLogfFunc.

func (*QorJobInterfaceMock) AddLogfCalls

func (mock *QorJobInterfaceMock) AddLogfCalls() []struct {
	Format string
	A      []interface{}
}

AddLogfCalls gets all the calls that were made to AddLogf. Check the length with:

len(mockedQorJobInterface.AddLogfCalls())

func (*QorJobInterfaceMock) GetJobInfo

func (mock *QorJobInterfaceMock) GetJobInfo() (*worker.JobInfo, error)

GetJobInfo calls GetJobInfoFunc.

func (*QorJobInterfaceMock) GetJobInfoCalls

func (mock *QorJobInterfaceMock) GetJobInfoCalls() []struct {
}

GetJobInfoCalls gets all the calls that were made to GetJobInfo. Check the length with:

len(mockedQorJobInterface.GetJobInfoCalls())

func (*QorJobInterfaceMock) SetProgress

func (mock *QorJobInterfaceMock) SetProgress(v uint) error

SetProgress calls SetProgressFunc.

func (*QorJobInterfaceMock) SetProgressCalls

func (mock *QorJobInterfaceMock) SetProgressCalls() []struct {
	V uint
}

SetProgressCalls gets all the calls that were made to SetProgress. Check the length with:

len(mockedQorJobInterface.SetProgressCalls())

func (*QorJobInterfaceMock) SetProgressText

func (mock *QorJobInterfaceMock) SetProgressText(s string) error

SetProgressText calls SetProgressTextFunc.

func (*QorJobInterfaceMock) SetProgressTextCalls

func (mock *QorJobInterfaceMock) SetProgressTextCalls() []struct {
	S string
}

SetProgressTextCalls gets all the calls that were made to SetProgressText. Check the length with:

len(mockedQorJobInterface.SetProgressTextCalls())

type QueueMock

type QueueMock struct {
	// AddFunc mocks the Add method.
	AddFunc func(ctx context.Context, job worker.QueJobInterface) error

	// KillFunc mocks the Kill method.
	KillFunc func(ctx context.Context, job worker.QueJobInterface) error

	// ListenFunc mocks the Listen method.
	ListenFunc func(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error

	// RemoveFunc mocks the Remove method.
	RemoveFunc func(ctx context.Context, job worker.QueJobInterface) error

	// ShutdownFunc mocks the Shutdown method.
	ShutdownFunc func(ctx context.Context) error
	// contains filtered or unexported fields
}

QueueMock is a mock implementation of worker.Queue.

func TestSomethingThatUsesQueue(t *testing.T) {

	// make and configure a mocked worker.Queue
	mockedQueue := &QueueMock{
		AddFunc: func(ctx context.Context, job worker.QueJobInterface) error {
			panic("mock out the Add method")
		},
		KillFunc: func(ctx context.Context, job worker.QueJobInterface) error {
			panic("mock out the Kill method")
		},
		ListenFunc: func(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error {
			panic("mock out the Listen method")
		},
		RemoveFunc: func(ctx context.Context, job worker.QueJobInterface) error {
			panic("mock out the Remove method")
		},
		ShutdownFunc: func(ctx context.Context) error {
			panic("mock out the Shutdown method")
		},
	}

	// use mockedQueue in code that requires worker.Queue
	// and then make assertions.

}

func (*QueueMock) Add

func (mock *QueueMock) Add(ctx context.Context, job worker.QueJobInterface) error

Add calls AddFunc.

func (*QueueMock) AddCalls

func (mock *QueueMock) AddCalls() []struct {
	Ctx context.Context
	Job worker.QueJobInterface
}

AddCalls gets all the calls that were made to Add. Check the length with:

len(mockedQueue.AddCalls())

func (*QueueMock) Kill

func (mock *QueueMock) Kill(ctx context.Context, job worker.QueJobInterface) error

Kill calls KillFunc.

func (*QueueMock) KillCalls

func (mock *QueueMock) KillCalls() []struct {
	Ctx context.Context
	Job worker.QueJobInterface
}

KillCalls gets all the calls that were made to Kill. Check the length with:

len(mockedQueue.KillCalls())

func (*QueueMock) Listen

func (mock *QueueMock) Listen(jobDefs []*worker.QorJobDefinition, getJob func(qorJobID uint) (worker.QueJobInterface, error)) error

Listen calls ListenFunc.

func (*QueueMock) ListenCalls

func (mock *QueueMock) ListenCalls() []struct {
	JobDefs []*worker.QorJobDefinition
	GetJob  func(qorJobID uint) (worker.QueJobInterface, error)
}

ListenCalls gets all the calls that were made to Listen. Check the length with:

len(mockedQueue.ListenCalls())

func (*QueueMock) Remove

func (mock *QueueMock) Remove(ctx context.Context, job worker.QueJobInterface) error

Remove calls RemoveFunc.

func (*QueueMock) RemoveCalls

func (mock *QueueMock) RemoveCalls() []struct {
	Ctx context.Context
	Job worker.QueJobInterface
}

RemoveCalls gets all the calls that were made to Remove. Check the length with:

len(mockedQueue.RemoveCalls())

func (*QueueMock) Shutdown

func (mock *QueueMock) Shutdown(ctx context.Context) error

Shutdown calls ShutdownFunc.

func (*QueueMock) ShutdownCalls

func (mock *QueueMock) ShutdownCalls() []struct {
	Ctx context.Context
}

ShutdownCalls gets all the calls that were made to Shutdown. Check the length with:

len(mockedQueue.ShutdownCalls())

Jump to

Keyboard shortcuts

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