mockdb

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Mar 21, 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
	OnStat                          func(string) (string, error)
	OnCompact                       func([]byte, []byte) error
	OnClose                         func() error
}

Database implements database.Database. This 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

Close implements the database.Database interface

func (*Database) Compact

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

Compact implements the database.Database interface

func (*Database) Delete

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

Delete implements the database.Database interface

func (*Database) Get

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

Get implements the database.Database interface

func (*Database) Has

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

Has implements the database.Database interface

func (*Database) NewBatch

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

NewBatch implements the database.Database interface

func (*Database) NewIterator

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

NewIterator implements the database.Database interface

func (*Database) NewIteratorWithPrefix

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

NewIteratorWithPrefix implements the database.Database interface

func (*Database) NewIteratorWithStart

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

NewIteratorWithStart implements the database.Database interface

func (*Database) NewIteratorWithStartAndPrefix

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

NewIteratorWithStartAndPrefix implements the database.Database interface

func (*Database) Put

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

Put implements the database.Database interface

func (*Database) Stat

func (db *Database) Stat(stat string) (string, error)

Stat implements the database.Database interface

Jump to

Keyboard shortcuts

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