Package testutil
import "github.com/syndtr/goleveldb/leveldb/testutil"
- Overview
- Index
- func AllKeyValueTesting(rnd *rand.Rand, body, setup func(KeyValue) DB, teardown func(DB))
- func BytesAfter(b []byte) []byte
- func BytesSeparator(a, b []byte) []byte
- func Defer(args ...interface{}) bool
- func DoDBTesting(t *DBTesting)
- func DoIteratorTesting(t *IteratorTesting)
- func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB))
- func Max(x, y int) int
- func Min(x, y int) int
- func NewRand() *rand.Rand
- func RandomIndex(rnd *rand.Rand, n, round int, fn func(i int))
- func RandomRange(rnd *rand.Rand, n, round int, fn func(start, limit int))
- func RandomSeed() int64
- func RunDefer(groups ...string) bool
- func RunSuite(t GinkgoTestingT, name string)
- func ShuffledIndex(rnd *rand.Rand, n, round int, fn func(i int))
- func TestFind(db Find, kv KeyValue)
- func TestFindAfterLast(db Find, kv KeyValue)
- func TestGet(db Get, kv KeyValue)
- func TestHas(db Has, kv KeyValue)
- func TestIter(db NewIterator, r *util.Range, kv KeyValue)
- type DB
- type DBAct
- func (a DBAct) String() string
- type DBTesting
- func (t *DBTesting) Delete(key []byte)
- func (t *DBTesting) DeleteRandom() bool
- func (t *DBTesting) Put(key, value []byte)
- func (t *DBTesting) PutRandom() bool
- func (t *DBTesting) RandomAct(round int)
- func (t *DBTesting) TestAll()
- func (t *DBTesting) TestAllDeleted()
- func (t *DBTesting) TestAllPresent()
- func (t *DBTesting) TestDeletedKey(key []byte)
- func (t *DBTesting) TestPresentKV(key, value []byte)
- func (t *DBTesting) Text() string
- type Delete
- type Find
- type Get
- type Has
- type IterAct
- func (a IterAct) String() string
- type IteratorTesting
- func (t *IteratorTesting) EOI()
- func (t *IteratorTesting) First()
- func (t *IteratorTesting) IsFirst() bool
- func (t *IteratorTesting) IsLast() bool
- func (t *IteratorTesting) Last()
- func (t *IteratorTesting) Next()
- func (t *IteratorTesting) NextAll()
- func (t *IteratorTesting) Prev()
- func (t *IteratorTesting) PrevAll()
- func (t *IteratorTesting) SOI()
- func (t *IteratorTesting) Seek(i int)
- func (t *IteratorTesting) SeekInexact(i int)
- func (t *IteratorTesting) SeekKey(key []byte)
- func (t *IteratorTesting) TestKV()
- func (t *IteratorTesting) Text() string
- func (t *IteratorTesting) WalkNext(fn func(t *IteratorTesting))
- func (t *IteratorTesting) WalkPrev(fn func(t *IteratorTesting))
- type KeyValue
- func KeyValue_BigValue() *KeyValue
- func KeyValue_EmptyKey() *KeyValue
- func KeyValue_EmptyValue() *KeyValue
- func KeyValue_Generate(rnd *rand.Rand, n, incr, minlen, maxlen, vminlen, vmaxlen int) *KeyValue
- func KeyValue_MultipleKeyValue() *KeyValue
- func KeyValue_OneKeyValue() *KeyValue
- func KeyValue_SpecialKey() *KeyValue
- func (kv KeyValue) Clone() KeyValue
- func (kv *KeyValue) Delete(key []byte) (exist bool, value []byte)
- func (kv *KeyValue) DeleteIndex(i int) bool
- func (kv KeyValue) Get(key []byte) (i int, exist bool)
- func (kv KeyValue) GetString(key string) (i int, exist bool)
- func (kv KeyValue) Index(i int) (key, value []byte)
- func (kv KeyValue) IndexInexact(i int) (key_, key, value []byte)
- func (kv KeyValue) IndexOrNil(i int) (key, value []byte)
- func (kv KeyValue) IndexString(i int) (key, value string)
- func (kv KeyValue) Iterate(fn func(i int, key, value []byte))
- func (kv KeyValue) IterateInexact(fn func(i int, key_, key, value []byte))
- func (kv KeyValue) IterateInexactString(fn func(i int, key_, key, value string))
- func (kv KeyValue) IterateShuffled(rnd *rand.Rand, fn func(i int, key, value []byte))
- func (kv KeyValue) IterateShuffledString(rnd *rand.Rand, fn func(i int, key, value string))
- func (kv KeyValue) IterateString(fn func(i int, key, value string))
- func (kv KeyValue) KeyAt(i int) []byte
- func (kv KeyValue) Len() int
- func (kv *KeyValue) Put(key, value []byte)
- func (kv *KeyValue) PutString(key, value string)
- func (kv *KeyValue) PutU(key, value []byte) bool
- func (kv *KeyValue) PutUString(key, value string) bool
- func (kv KeyValue) Range(start, limit int) (r util.Range)
- func (kv KeyValue) Search(key []byte) int
- func (kv KeyValue) SearchString(key string) int
- func (kv *KeyValue) Size() int
- func (kv KeyValue) Slice(start, limit int) KeyValue
- func (kv KeyValue) SliceKey(start, limit []byte) KeyValue
- func (kv KeyValue) SliceKeyString(start, limit string) KeyValue
- func (kv KeyValue) SliceRange(r *util.Range) KeyValue
- func (kv KeyValue) ValueAt(i int) []byte
- type KeyValueEntry
- type NewIterator
- type Put
- type Storage
- func NewStorage() *Storage
- func (s *Storage) Close() error
- func (s *Storage) CloseCheck()
- func (s *Storage) Counter(m StorageMode, t storage.FileType) (count int, bytes int64)
- func (s *Storage) Create(fd storage.FileDesc) (w storage.Writer, err error)
- func (s *Storage) EmulateError(m StorageMode, t storage.FileType, err error)
- func (s *Storage) EmulateErrorOnce(m StorageMode, t storage.FileType, err error)
- func (s *Storage) EmulateRandomError(m StorageMode, t storage.FileType, prob float64, err error)
- func (s *Storage) ForceRemove(fd storage.FileDesc) (err error)
- func (s *Storage) ForceRename(oldfd, newfd storage.FileDesc) (err error)
- func (s *Storage) GetMeta() (fd storage.FileDesc, err error)
- func (s *Storage) List(t storage.FileType) (fds []storage.FileDesc, err error)
- func (s *Storage) Lock() (l storage.Locker, err error)
- func (s *Storage) Log(str string)
- func (s *Storage) OnClose(onClose func() (preserve bool, err error))
- func (s *Storage) OnLog(onLog func(log string))
- func (s *Storage) Open(fd storage.FileDesc) (r storage.Reader, err error)
- func (s *Storage) Release(m StorageMode, t storage.FileType)
- func (s *Storage) Remove(fd storage.FileDesc) (err error)
- func (s *Storage) Rename(oldfd, newfd storage.FileDesc) (err error)
- func (s *Storage) ResetCounter(m StorageMode, t storage.FileType)
- func (s *Storage) SetMeta(fd storage.FileDesc) error
- func (s *Storage) Stall(m StorageMode, t storage.FileType)
- type StorageMode
Package files
db.go
ginkgo.go
iter.go
kv.go
kvtest.go
storage.go
util.go
func AllKeyValueTesting(rnd *rand.Rand, body, setup func(KeyValue) DB, teardown func(DB))
func BytesAfter(b []byte) []byte
func BytesSeparator(a, b []byte) []byte
func Defer(args ...interface{}) bool
func DoDBTesting(t *DBTesting)
func DoIteratorTesting(t *IteratorTesting)
func KeyValueTesting(rnd *rand.Rand, kv KeyValue, p DB, setup func(KeyValue) DB, teardown func(DB))
func Max(x, y int) int
func Min(x, y int) int
func NewRand() *rand.Rand
func RandomIndex(rnd *rand.Rand, n, round int, fn func(i int))
func RandomRange(rnd *rand.Rand, n, round int, fn func(start, limit int))
func RandomSeed() int64
func RunDefer(groups ...string) bool
func RunSuite(t GinkgoTestingT, name string)
func ShuffledIndex(rnd *rand.Rand, n, round int, fn func(i int))
func TestFind(db Find, kv KeyValue)
func TestFindAfterLast(db Find, kv KeyValue)
func TestGet(db Get, kv KeyValue)
func TestHas(db Has, kv KeyValue)
func TestIter(db NewIterator, r *util.Range, kv KeyValue)
type DB interface{}
type DBAct int
const (
DBNone DBAct = iota
DBPut
DBOverwrite
DBDelete
DBDeleteNA
)
func (a DBAct) String() string
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 (t *DBTesting) DeleteRandom() bool
func (*DBTesting) Put
¶
func (t *DBTesting) Put(key, value []byte)
func (t *DBTesting) PutRandom() bool
func (t *DBTesting) RandomAct(round int)
func (*DBTesting) TestAll
¶
func (t *DBTesting) TestAll()
func (t *DBTesting) TestAllDeleted()
func (t *DBTesting) TestAllPresent()
func (t *DBTesting) TestDeletedKey(key []byte)
func (t *DBTesting) TestPresentKV(key, value []byte)
func (*DBTesting) Text
¶
func (t *DBTesting) Text() string
type Delete interface {
TestDelete(key []byte) error
}
type Find interface {
TestFind(key []byte) (rkey, rvalue []byte, err error)
}
type Get interface {
TestGet(key []byte) (value []byte, err error)
}
type Has interface {
TestHas(key []byte) (ret bool, err error)
}
type IterAct int
const (
IterNone IterAct = iota
IterFirst
IterLast
IterPrev
IterNext
IterSeek
IterSOI
IterEOI
)
func (IterAct) String
¶
func (a IterAct) String() string
type IteratorTesting struct {
KeyValue
Iter iterator.Iterator
Rand *rand.Rand
PostFn func(t *IteratorTesting)
Pos int
Act, LastAct IterAct
}
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 struct {
}
func KeyValue_BigValue() *KeyValue
func KeyValue_EmptyKey() *KeyValue
func KeyValue_EmptyValue() *KeyValue
func KeyValue_Generate(rnd *rand.Rand, n, incr, minlen, maxlen, vminlen, vmaxlen int) *KeyValue
func KeyValue_MultipleKeyValue() *KeyValue
func KeyValue_OneKeyValue() *KeyValue
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 (kv *KeyValue) DeleteIndex(i int) bool
func (KeyValue) Get
¶
func (kv KeyValue) Get(key []byte) (i int, exist bool)
func (kv KeyValue) GetString(key string) (i int, exist bool)
func (KeyValue) Index
¶
func (kv KeyValue) Index(i int) (key, value []byte)
func (kv KeyValue) IndexInexact(i int) (key_, key, value []byte)
func (kv KeyValue) IndexOrNil(i int) (key, value []byte)
func (kv KeyValue) IndexString(i int) (key, value string)
func (KeyValue) Iterate
¶
func (kv KeyValue) Iterate(fn func(i int, key, value []byte))
func (kv KeyValue) IterateInexact(fn func(i int, key_, key, value []byte))
func (kv KeyValue) IterateInexactString(fn func(i int, key_, key, value string))
func (kv KeyValue) IterateShuffled(rnd *rand.Rand, fn func(i int, key, value []byte))
func (kv KeyValue) IterateShuffledString(rnd *rand.Rand, fn func(i int, key, value string))
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 (kv *KeyValue) PutString(key, value string)
func (*KeyValue) PutU
¶
func (kv *KeyValue) PutU(key, value []byte) bool
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 (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 (kv KeyValue) SliceKey(start, limit []byte) KeyValue
func (kv KeyValue) SliceKeyString(start, limit string) KeyValue
func (kv KeyValue) SliceRange(r *util.Range) KeyValue
func (KeyValue) ValueAt
¶
func (kv KeyValue) ValueAt(i int) []byte
type KeyValueEntry struct {
}
type NewIterator interface {
TestNewIterator(slice *util.Range) iterator.Iterator
}
type Put interface {
TestPut(key []byte, value []byte) error
}
type Storage struct {
storage.Storage
}
func NewStorage() *Storage
func (*Storage) Close
¶
func (s *Storage) Close() error
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 (s *Storage) EmulateError(m StorageMode, t storage.FileType, err error)
func (s *Storage) EmulateErrorOnce(m StorageMode, t storage.FileType, err error)
func (s *Storage) EmulateRandomError(m StorageMode, t storage.FileType, prob float64, err error)
func (s *Storage) ForceRemove(fd storage.FileDesc) (err error)
func (s *Storage) ForceRename(oldfd, newfd storage.FileDesc) (err error)
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 (s *Storage) ResetCounter(m StorageMode, t storage.FileType)
func (s *Storage) SetMeta(fd storage.FileDesc) error
func (*Storage) Stall
¶
func (s *Storage) Stall(m StorageMode, t storage.FileType)
type StorageMode int
const (
ModeOpen StorageMode = 1 << iota
ModeCreate
ModeRemove
ModeRename
ModeRead
ModeWrite
ModeSync
ModeClose
)