mockdb

package
v1.7.13-rc.7 Latest Latest
Warning

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

Go to latest
Published: Aug 2, 2022 License: BSD-3-Clause Imports: 2 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Database

type Database struct {
	// Executed when Has is called
	OnHas                           func([]byte) (bool, error)
	OnGet                           func([]byte) ([]byte, error)
	OnPut                           func([]byte, []byte) error
	OnDelete                        func([]byte) error
	OnNewBatch                      func() database.Batch
	OnNewIterator                   func() database.Iterator
	OnNewIteratorWithStart          func([]byte) database.Iterator
	OnNewIteratorWithPrefix         func([]byte) database.Iterator
	OnNewIteratorWithStartAndPrefix func([]byte, []byte) database.Iterator
	OnCompact                       func([]byte, []byte) error
	OnClose                         func() error
	OnHealthCheck                   func() (interface{}, error)
}

Database is a mock database meant to be used in tests. You specify the database's return value(s) for a given method call by assign value to the corresponding member. For example, to specify what should happen when Has is called, assign a value to OnHas. If no value is assigned to the corresponding member, the method returns an error or nil If you

func New

func New() *Database

New returns a new mock database

func (*Database) Close

func (db *Database) Close() error

func (*Database) Compact

func (db *Database) Compact(start []byte, limit []byte) error

func (*Database) Delete

func (db *Database) Delete(k []byte) error

func (*Database) Get

func (db *Database) Get(k []byte) ([]byte, error)

func (*Database) Has

func (db *Database) Has(k []byte) (bool, error)

func (*Database) HealthCheck added in v1.7.16

func (db *Database) HealthCheck() (interface{}, error)

func (*Database) NewBatch

func (db *Database) NewBatch() database.Batch

func (*Database) NewIterator

func (db *Database) NewIterator() database.Iterator

func (*Database) NewIteratorWithPrefix

func (db *Database) NewIteratorWithPrefix(prefix []byte) database.Iterator

func (*Database) NewIteratorWithStart

func (db *Database) NewIteratorWithStart(start []byte) database.Iterator

func (*Database) NewIteratorWithStartAndPrefix

func (db *Database) NewIteratorWithStartAndPrefix(start, prefix []byte) database.Iterator

func (*Database) Put

func (db *Database) Put(k, v []byte) error

Jump to

Keyboard shortcuts

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