mock

package
v0.19.2 Latest Latest
Warning

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

Go to latest
Published: Jun 7, 2022 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type KVQueueMock

type KVQueueMock struct {
	// DequeueFunc mocks the Dequeue method.
	DequeueFunc func(value codec.ProtoMarshaler, filter ...func(value codec.ProtoMarshaler) bool) bool

	// EnqueueFunc mocks the Enqueue method.
	EnqueueFunc func(key utils.Key, value codec.ProtoMarshaler)

	// IsEmptyFunc mocks the IsEmpty method.
	IsEmptyFunc func() bool

	// KeysFunc mocks the Keys method.
	KeysFunc func() []utils.Key
	// contains filtered or unexported fields
}

KVQueueMock is a mock implementation of utils.KVQueue.

func TestSomethingThatUsesKVQueue(t *testing.T) {

	// make and configure a mocked utils.KVQueue
	mockedKVQueue := &KVQueueMock{
		DequeueFunc: func(value codec.ProtoMarshaler, filter ...func(value codec.ProtoMarshaler) bool) bool {
			panic("mock out the Dequeue method")
		},
		EnqueueFunc: func(key utils.Key, value codec.ProtoMarshaler)  {
			panic("mock out the Enqueue method")
		},
		IsEmptyFunc: func() bool {
			panic("mock out the IsEmpty method")
		},
		KeysFunc: func() []utils.Key {
			panic("mock out the Keys method")
		},
	}

	// use mockedKVQueue in code that requires utils.KVQueue
	// and then make assertions.

}

func (*KVQueueMock) Dequeue

func (mock *KVQueueMock) Dequeue(value codec.ProtoMarshaler, filter ...func(value codec.ProtoMarshaler) bool) bool

Dequeue calls DequeueFunc.

func (*KVQueueMock) DequeueCalls

func (mock *KVQueueMock) DequeueCalls() []struct {
	Value  codec.ProtoMarshaler
	Filter []func(value codec.ProtoMarshaler) bool
}

DequeueCalls gets all the calls that were made to Dequeue. Check the length with:

len(mockedKVQueue.DequeueCalls())

func (*KVQueueMock) Enqueue

func (mock *KVQueueMock) Enqueue(key utils.Key, value codec.ProtoMarshaler)

Enqueue calls EnqueueFunc.

func (*KVQueueMock) EnqueueCalls

func (mock *KVQueueMock) EnqueueCalls() []struct {
	Key   utils.Key
	Value codec.ProtoMarshaler
}

EnqueueCalls gets all the calls that were made to Enqueue. Check the length with:

len(mockedKVQueue.EnqueueCalls())

func (*KVQueueMock) IsEmpty

func (mock *KVQueueMock) IsEmpty() bool

IsEmpty calls IsEmptyFunc.

func (*KVQueueMock) IsEmptyCalls

func (mock *KVQueueMock) IsEmptyCalls() []struct {
}

IsEmptyCalls gets all the calls that were made to IsEmpty. Check the length with:

len(mockedKVQueue.IsEmptyCalls())

func (*KVQueueMock) Keys added in v0.10.0

func (mock *KVQueueMock) Keys() []utils.Key

Keys calls KeysFunc.

func (*KVQueueMock) KeysCalls added in v0.10.0

func (mock *KVQueueMock) KeysCalls() []struct {
}

KeysCalls gets all the calls that were made to Keys. Check the length with:

len(mockedKVQueue.KeysCalls())

type LoggerMock added in v0.17.0

type LoggerMock struct {
	// LoggerFunc mocks the Logger method.
	LoggerFunc func(ctx sdk.Context) log.Logger
	// contains filtered or unexported fields
}

LoggerMock is a mock implementation of utils.Logger.

func TestSomethingThatUsesLogger(t *testing.T) {

	// make and configure a mocked utils.Logger
	mockedLogger := &LoggerMock{
		LoggerFunc: func(ctx sdk.Context) log.Logger {
			panic("mock out the Logger method")
		},
	}

	// use mockedLogger in code that requires utils.Logger
	// and then make assertions.

}

func (*LoggerMock) Logger added in v0.17.0

func (mock *LoggerMock) Logger(ctx sdk.Context) log.Logger

Logger calls LoggerFunc.

func (*LoggerMock) LoggerCalls added in v0.17.0

func (mock *LoggerMock) LoggerCalls() []struct {
	Ctx sdk.Context
}

LoggerCalls gets all the calls that were made to Logger. Check the length with:

len(mockedLogger.LoggerCalls())

Jump to

Keyboard shortcuts

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