testutil

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Jan 7, 2020 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

Codecs we want to test.

View Source
var DbInitalizer = []func(db.Codec) db.DB{
	func(codec db.Codec) db.DB {
		return memdb.New(codec)
	},
	func(codec db.Codec) db.DB {
		return leveldb.New(".leveldb", codec)
	},
	func(codec db.Codec) db.DB {
		return badgerdb.New(".badgerdb", codec)
	},
}

DbInitalizer returns a list of initialize functions of different DB implementations.

Functions

func CheckErrors

func CheckErrors(errs []error) error

CheckErrors takes a list of errors and check if any of them is not nil. It returns the first non-nil error or nil if all of the errors are nil.

func RandomNonDupStrings

func RandomNonDupStrings(i int) []string

RandomNonDupStrings returns a list of non-duplicate strings.

func RandomTestStructGroups

func RandomTestStructGroups(group, entriesPerGroup int) [][]TestStruct

RandomTestStructGroups creates a group of random TestStructs.

Types

type TestStruct

type TestStruct struct {
	A string
	B int
	C bool
	D []byte
	E map[string]float64
}

TestStruct is a struct which includes some commonly used types.

func RandomTestStruct

func RandomTestStruct() TestStruct

RandomTestStruct returns a random `TestStruct`

func (TestStruct) MarshalBinary added in v1.0.3

func (s TestStruct) MarshalBinary() ([]byte, error)

MarshalBinary implements the `BinaryMarshaler` interface.

func (*TestStruct) UnmarshalBinary added in v1.0.3

func (s *TestStruct) UnmarshalBinary(data []byte) error

UnmarshalBinary implements the `BinaryUnmarshaler` interface.

Jump to

Keyboard shortcuts

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