mock

package
v0.0.0-...-73c3907 Latest Latest
Warning

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

Go to latest
Published: May 6, 2023 License: MIT Imports: 2 Imported by: 0

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(queJobInterface worker.QueJobInterface) error

	// KillFunc mocks the Kill method.
	KillFunc func(queJobInterface 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(queJobInterface worker.QueJobInterface) 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(queJobInterface worker.QueJobInterface) error {
			panic("mock out the Add method")
		},
		KillFunc: func(queJobInterface 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(queJobInterface worker.QueJobInterface) error {
			panic("mock out the Remove method")
		},
	}

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

}

func (*QueueMock) Add

func (mock *QueueMock) Add(queJobInterface worker.QueJobInterface) error

Add calls AddFunc.

func (*QueueMock) AddCalls

func (mock *QueueMock) AddCalls() []struct {
	QueJobInterface 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(queJobInterface worker.QueJobInterface) error

Kill calls KillFunc.

func (*QueueMock) KillCalls

func (mock *QueueMock) KillCalls() []struct {
	QueJobInterface 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(queJobInterface worker.QueJobInterface) error

Remove calls RemoveFunc.

func (*QueueMock) RemoveCalls

func (mock *QueueMock) RemoveCalls() []struct {
	QueJobInterface worker.QueJobInterface
}

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

len(mockedQueue.RemoveCalls())

Jump to

Keyboard shortcuts

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