mocks

package
v0.1.5 Latest Latest
Warning

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

Go to latest
Published: Dec 8, 2020 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package mocks provides useful mocks for testing different command controller features.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type MockIterator

type MockIterator struct {
	// contains filtered or unexported fields
}

MockIterator is the mock implementation of storage iterator.

func NewMockIterator

func NewMockIterator(batch [][]string) *MockIterator

NewMockIterator returns new mock iterator for given batch.

func NewMockIteratorWithError

func NewMockIteratorWithError(err error) *MockIterator

NewMockIteratorWithError returns new mock iterator with error.

func (*MockIterator) Error

func (s *MockIterator) Error() error

Error returns error in iterator.

func (*MockIterator) Key

func (s *MockIterator) Key() []byte

Key returns the key of the current key/value pair.

func (*MockIterator) Next

func (s *MockIterator) Next() bool

Next moves pointer to next value of iterator. It returns false if the iterator is exhausted.

func (*MockIterator) Release

func (s *MockIterator) Release()

Release releases associated resources.

func (*MockIterator) Value

func (s *MockIterator) Value() []byte

Value returns the value of the current key/value pair.

type MockStore

type MockStore struct {
	Store map[string][]byte

	ErrPut    error
	ErrGet    error
	ErrItr    error
	ErrDelete error
	// contains filtered or unexported fields
}

MockStore mock store.

func (*MockStore) Delete

func (s *MockStore) Delete(k string) error

Delete will delete record with k key.

func (*MockStore) Get

func (s *MockStore) Get(k string) ([]byte, error)

Get fetches the record based on key.

func (*MockStore) Iterator

func (s *MockStore) Iterator(start, limit string) storage.StoreIterator

Iterator returns an iterator for the underlying mockstore.

func (*MockStore) Put

func (s *MockStore) Put(k string, v []byte) error

Put stores the key and the record.

type MockStoreProvider

type MockStoreProvider struct {
	Store              *MockStore
	Custom             storage.Store
	ErrOpenStoreHandle error
	ErrClose           error
	ErrCloseStore      error
	FailNamespace      string
	ErrFlush           error
}

MockStoreProvider mock store provider.

func NewCustomMockStoreProvider

func NewCustomMockStoreProvider(customStore storage.Store) *MockStoreProvider

NewCustomMockStoreProvider new mock store provider instance from existing mock store.

func NewMockStoreProvider

func NewMockStoreProvider() *MockStoreProvider

NewMockStoreProvider new store provider instance.

func (*MockStoreProvider) Close

func (s *MockStoreProvider) Close() error

Close closes all stores created under this store provider.

func (*MockStoreProvider) CloseStore

func (s *MockStoreProvider) CloseStore(name string) error

CloseStore closes store for given name space.

func (*MockStoreProvider) Flush

func (s *MockStoreProvider) Flush() error

Flush data.

func (*MockStoreProvider) OpenStore

func (s *MockStoreProvider) OpenStore(name string) (storage.Store, error)

OpenStore opens and returns a store for given name space.

type Notifier

type Notifier struct {
	NotifyFunc func(topic string, message []byte) error
}

Notifier is mock implementation of notifier.

func NewMockNotifier

func NewMockNotifier() *Notifier

NewMockNotifier returns mock notifier implementation.

func (*Notifier) Notify

func (n *Notifier) Notify(topic string, message []byte) error

Notify is mock implementation of notifier Notify().

Directories

Path Synopsis
Package protocol provides useful mocks for testing different command controller features.
Package protocol provides useful mocks for testing different command controller features.

Jump to

Keyboard shortcuts

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