testutil

package
v0.0.0-...-2acd411 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2022 License: BSD-2-Clause Imports: 20 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AllKeyValueTesting

func AllKeyValueTesting(rnd *rand.Rand, body, setup func(KeyValue) DB, teardown func(DB))

func BytesAfter

func BytesAfter(b []byte) []byte

func BytesSeparator

func BytesSeparator(a, b []byte) []byte

func Defer

func Defer(args ...interface{}) bool

func DoDBTesting

func DoDBTesting(t *DBTesting)

func DoIteratorTesting

func DoIteratorTesting(t *IteratorTesting)

func KeyValueTesting

func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB))

func Max

func Max(x, y int) int

func Min

func Min(x, y int) int

func NewRand

func NewRand() *rand.Rand

func RandomIndex

func RandomIndex(rnd *rand.Rand, n, round int, fn func(i int))

func RandomRange

func RandomRange(rnd *rand.Rand, n, round int, fn func(start, limit int))

func RandomSeed

func RandomSeed() int64

func RunDefer

func RunDefer(groups ...string) bool

func RunSuite

func RunSuite(t GinkgoTestingT, name string)

func ShuffledIndex

func ShuffledIndex(rnd *rand.Rand, n, round int, fn func(i int))

func TestFind

func TestFind(db Find, kv KeyValue)

func TestFindAfterLast

func TestFindAfterLast(db Find, kv KeyValue)

func TestGet

func TestGet(db Get, kv KeyValue)

func TestHas

func TestHas(db Has, kv KeyValue)

func TestIter

func TestIter(db NewIterator, r *util.Range, kv KeyValue)

Types

type DB

type DB interface{}

type DBAct

type DBAct int
const (
	DBNone DBAct = iota
	DBPut
	DBOverwrite
	DBDelete
	DBDeleteNA
)

func (DBAct) String

func (a DBAct) String() string

type DBTesting

type DBTesting struct {
	Rand *rand.Rand
	DB   interface {
		Get
		Put
		Delete
	}
	PostFn             func(t *DBTesting)
	Deleted, Present   KeyValue
	Act, LastAct       DBAct
	ActKey, LastActKey []byte
}

func (*DBTesting) Delete

func (t *DBTesting) Delete(key []byte)

func (*DBTesting) DeleteRandom

func (t *DBTesting) DeleteRandom() bool

func (*DBTesting) Put

func (t *DBTesting) Put(key, value []byte)

func (*DBTesting) PutRandom

func (t *DBTesting) PutRandom() bool

func (*DBTesting) RandomAct

func (t *DBTesting) RandomAct(round int)

func (*DBTesting) TestAll

func (t *DBTesting) TestAll()

func (*DBTesting) TestAllDeleted

func (t *DBTesting) TestAllDeleted()

func (*DBTesting) TestAllPresent

func (t *DBTesting) TestAllPresent()

func (*DBTesting) TestDeletedKey

func (t *DBTesting) TestDeletedKey(key []byte)

func (*DBTesting) TestPresentKV

func (t *DBTesting) TestPresentKV(key, value []byte)

func (*DBTesting) Text

func (t *DBTesting) Text() string

type Delete

type Delete interface {
	TestDelete(key []byte) error
}

type Find

type Find interface {
	TestFind(key []byte) (rkey, rvalue []byte, err error)
}

type Get

type Get interface {
	TestGet(key []byte) (value []byte, err error)
}

type Has

type Has interface {
	TestHas(key []byte) (ret bool, err error)
}

type IterAct

type IterAct int
const (
	IterNone IterAct = iota
	IterFirst
	IterLast
	IterPrev
	IterNext
	IterSeek
	IterSOI
	IterEOI
)

func (IterAct) String

func (a IterAct) String() string

type IteratorTesting

type IteratorTesting struct {
	KeyValue
	Iter         iterator.Iterator
	Rand         *rand.Rand
	PostFn       func(t *IteratorTesting)
	Pos          int
	Act, LastAct IterAct
	// contains filtered or unexported fields
}

func (*IteratorTesting) EOI

func (t *IteratorTesting) EOI()

func (*IteratorTesting) First

func (t *IteratorTesting) First()

func (*IteratorTesting) IsFirst

func (t *IteratorTesting) IsFirst() bool

func (*IteratorTesting) IsLast

func (t *IteratorTesting) IsLast() bool

func (*IteratorTesting) Last

func (t *IteratorTesting) Last()

func (*IteratorTesting) Next

func (t *IteratorTesting) Next()

func (*IteratorTesting) NextAll

func (t *IteratorTesting) NextAll()

func (*IteratorTesting) Prev

func (t *IteratorTesting) Prev()

func (*IteratorTesting) PrevAll

func (t *IteratorTesting) PrevAll()

func (*IteratorTesting) SOI

func (t *IteratorTesting) SOI()

func (*IteratorTesting) Seek

func (t *IteratorTesting) Seek(i int)

func (*IteratorTesting) SeekInexact

func (t *IteratorTesting) SeekInexact(i int)

func (*IteratorTesting) SeekKey

func (t *IteratorTesting) SeekKey(key []byte)

func (*IteratorTesting) TestKV

func (t *IteratorTesting) TestKV()

func (*IteratorTesting) Text

func (t *IteratorTesting) Text() string

func (*IteratorTesting) WalkNext

func (t *IteratorTesting) WalkNext(fn func(t *IteratorTesting))

func (*IteratorTesting) WalkPrev

func (t *IteratorTesting) WalkPrev(fn func(t *IteratorTesting))

type KeyValue

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

func KeyValue_BigValue

func KeyValue_BigValue() *KeyValue

func KeyValue_EmptyKey

func KeyValue_EmptyKey() *KeyValue

func KeyValue_EmptyValue

func KeyValue_EmptyValue() *KeyValue

func KeyValue_Generate

func KeyValue_Generate(rnd *rand.Rand, n, incr, minlen, maxlen, vminlen, vmaxlen int) *KeyValue

func KeyValue_MultipleKeyValue

func KeyValue_MultipleKeyValue() *KeyValue

func KeyValue_OneKeyValue

func KeyValue_OneKeyValue() *KeyValue

func KeyValue_SpecialKey

func KeyValue_SpecialKey() *KeyValue

func (KeyValue) Clone

func (kv KeyValue) Clone() KeyValue

func (*KeyValue) Delete

func (kv *KeyValue) Delete(key []byte) (exist bool, value []byte)

func (*KeyValue) DeleteIndex

func (kv *KeyValue) DeleteIndex(i int) bool

func (KeyValue) Get

func (kv KeyValue) Get(key []byte) (i int, exist bool)

func (KeyValue) GetString

func (kv KeyValue) GetString(key string) (i int, exist bool)

func (KeyValue) Index

func (kv KeyValue) Index(i int) (key, value []byte)

func (KeyValue) IndexInexact

func (kv KeyValue) IndexInexact(i int) (key_, key, value []byte)

func (KeyValue) IndexOrNil

func (kv KeyValue) IndexOrNil(i int) (key, value []byte)

func (KeyValue) IndexString

func (kv KeyValue) IndexString(i int) (key, value string)

func (KeyValue) Iterate

func (kv KeyValue) Iterate(fn func(i int, key, value []byte))

func (KeyValue) IterateInexact

func (kv KeyValue) IterateInexact(fn func(i int, key_, key, value []byte))

func (KeyValue) IterateInexactString

func (kv KeyValue) IterateInexactString(fn func(i int, key_, key, value string))

func (KeyValue) IterateShuffled

func (kv KeyValue) IterateShuffled(rnd *rand.Rand, fn func(i int, key, value []byte))

func (KeyValue) IterateShuffledString

func (kv KeyValue) IterateShuffledString(rnd *rand.Rand, fn func(i int, key, value string))

func (KeyValue) IterateString

func (kv KeyValue) IterateString(fn func(i int, key, value string))

func (KeyValue) KeyAt

func (kv KeyValue) KeyAt(i int) []byte

func (KeyValue) Len

func (kv KeyValue) Len() int

func (*KeyValue) Put

func (kv *KeyValue) Put(key, value []byte)

func (*KeyValue) PutString

func (kv *KeyValue) PutString(key, value string)

func (*KeyValue) PutU

func (kv *KeyValue) PutU(key, value []byte) bool

func (*KeyValue) PutUString

func (kv *KeyValue) PutUString(key, value string) bool

func (KeyValue) Range

func (kv KeyValue) Range(start, limit int) (r util.Range)

func (KeyValue) Search

func (kv KeyValue) Search(key []byte) int

func (KeyValue) SearchString

func (kv KeyValue) SearchString(key string) int

func (*KeyValue) Size

func (kv *KeyValue) Size() int

func (KeyValue) Slice

func (kv KeyValue) Slice(start, limit int) KeyValue

func (KeyValue) SliceKey

func (kv KeyValue) SliceKey(start, limit []byte) KeyValue

func (KeyValue) SliceKeyString

func (kv KeyValue) SliceKeyString(start, limit string) KeyValue

func (KeyValue) SliceRange

func (kv KeyValue) SliceRange(r *util.Range) KeyValue

func (KeyValue) ValueAt

func (kv KeyValue) ValueAt(i int) []byte

type KeyValueEntry

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

type NewIterator

type NewIterator interface {
	TestNewIterator(slice *util.Range) iterator.Iterator
}

type Put

type Put interface {
	TestPut(key []byte, value []byte) error
}

type Storage

type Storage struct {
	storage.Storage
	// contains filtered or unexported fields
}

func NewStorage

func NewStorage() *Storage

func (*Storage) Close

func (s *Storage) Close() error

func (*Storage) CloseCheck

func (s *Storage) CloseCheck()

func (*Storage) Counter

func (s *Storage) Counter(m StorageMode, t storage.FileType) (count int, bytes int64)

func (*Storage) Create

func (s *Storage) Create(fd storage.FileDesc) (w storage.Writer, err error)

func (*Storage) EmulateError

func (s *Storage) EmulateError(m StorageMode, t storage.FileType, err error)

func (*Storage) EmulateErrorOnce

func (s *Storage) EmulateErrorOnce(m StorageMode, t storage.FileType, err error)

func (*Storage) EmulateRandomError

func (s *Storage) EmulateRandomError(m StorageMode, t storage.FileType, prob float64, err error)

func (*Storage) ForceRemove

func (s *Storage) ForceRemove(fd storage.FileDesc) (err error)

func (*Storage) ForceRename

func (s *Storage) ForceRename(oldfd, newfd storage.FileDesc) (err error)

func (*Storage) GetMeta

func (s *Storage) GetMeta() (fd storage.FileDesc, err error)

func (*Storage) List

func (s *Storage) List(t storage.FileType) (fds []storage.FileDesc, err error)

func (*Storage) Lock

func (s *Storage) Lock() (l storage.Locker, err error)

func (*Storage) Log

func (s *Storage) Log(str string)

func (*Storage) OnClose

func (s *Storage) OnClose(onClose func() (preserve bool, err error))

func (*Storage) OnLog

func (s *Storage) OnLog(onLog func(log string))

func (*Storage) Open

func (s *Storage) Open(fd storage.FileDesc) (r storage.Reader, err error)

func (*Storage) Release

func (s *Storage) Release(m StorageMode, t storage.FileType)

func (*Storage) Remove

func (s *Storage) Remove(fd storage.FileDesc) (err error)

func (*Storage) Rename

func (s *Storage) Rename(oldfd, newfd storage.FileDesc) (err error)

func (*Storage) ResetCounter

func (s *Storage) ResetCounter(m StorageMode, t storage.FileType)

func (*Storage) SetMeta

func (s *Storage) SetMeta(fd storage.FileDesc) error

func (*Storage) Stall

func (s *Storage) Stall(m StorageMode, t storage.FileType)

type StorageMode

type StorageMode int
const (
	ModeOpen StorageMode = 1 << iota
	ModeCreate
	ModeRemove
	ModeRename
	ModeRead
	ModeWrite
	ModeSync
	ModeClose
)

Jump to

Keyboard shortcuts

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