dplock

package
v3.8.0 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2024 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 ClientMock

type ClientMock struct {
	// UnlockFunc mocks the Unlock method.
	UnlockFunc func(ctx context.Context, lockID string) ([]lock.LockStatus, error)

	// XLockFunc mocks the XLock method.
	XLockFunc func(ctx context.Context, resourceName string, lockID string, ld lock.LockDetails) error
	// contains filtered or unexported fields
}

ClientMock is a mock implementation of Client.

func TestSomethingThatUsesClient(t *testing.T) {

	// make and configure a mocked Client
	mockedClient := &ClientMock{
		UnlockFunc: func(ctx context.Context, lockID string) ([]lock.LockStatus, error) {
			panic("mock out the Unlock method")
		},
		XLockFunc: func(ctx context.Context, resourceName string, lockID string, ld lock.LockDetails) error {
			panic("mock out the XLock method")
		},
	}

	// use mockedClient in code that requires Client
	// and then make assertions.

}

func (*ClientMock) Unlock

func (mock *ClientMock) Unlock(ctx context.Context, lockID string) ([]lock.LockStatus, error)

Unlock calls UnlockFunc.

func (*ClientMock) UnlockCalls

func (mock *ClientMock) UnlockCalls() []struct {
	Ctx    context.Context
	LockID string
}

UnlockCalls gets all the calls that were made to Unlock. Check the length with:

len(mockedClient.UnlockCalls())

func (*ClientMock) XLock

func (mock *ClientMock) XLock(ctx context.Context, resourceName string, lockID string, ld lock.LockDetails) error

XLock calls XLockFunc.

func (*ClientMock) XLockCalls

func (mock *ClientMock) XLockCalls() []struct {
	Ctx          context.Context
	ResourceName string
	LockID       string
	Ld           lock.LockDetails
}

XLockCalls gets all the calls that were made to XLock. Check the length with:

len(mockedClient.XLockCalls())

type PurgerMock

type PurgerMock struct {
	// PurgeFunc mocks the Purge method.
	PurgeFunc func(ctx context.Context) ([]lock.LockStatus, error)
	// contains filtered or unexported fields
}

PurgerMock is a mock implementation of Purger.

func TestSomethingThatUsesPurger(t *testing.T) {

	// make and configure a mocked Purger
	mockedPurger := &PurgerMock{
		PurgeFunc: func(ctx context.Context) ([]lock.LockStatus, error) {
			panic("mock out the Purge method")
		},
	}

	// use mockedPurger in code that requires Purger
	// and then make assertions.

}

func (*PurgerMock) Purge

func (mock *PurgerMock) Purge(ctx context.Context) ([]lock.LockStatus, error)

Purge calls PurgeFunc.

func (*PurgerMock) PurgeCalls

func (mock *PurgerMock) PurgeCalls() []struct {
	Ctx context.Context
}

PurgeCalls gets all the calls that were made to Purge. Check the length with:

len(mockedPurger.PurgeCalls())

Jump to

Keyboard shortcuts

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