migtest

package
v0.15.5-beta Latest Latest
Warning

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

Go to latest
Published: Dec 7, 2022 License: MIT Imports: 9 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ApplyMigration

func ApplyMigration(t *testing.T,
	beforeMigration, afterMigration, migrationFunc func(tx kvdb.RwTx) error,
	shouldFail bool)

ApplyMigration is a helper test function that encapsulates the general steps which are needed to properly check the result of applying migration function.

func ApplyMigrationWithDb

func ApplyMigrationWithDb(t testing.TB, beforeMigration, afterMigration,
	migrationFunc func(db kvdb.Backend) error)

ApplyMigrationWithDb is a helper test function that encapsulates the general steps which are needed to properly check the result of applying migration function. This function differs from ApplyMigration as it requires the supplied migration functions to take a db instance and construct their own database transactions.

func DumpDB

func DumpDB(tx kvdb.RTx, rootKey []byte) error

DumpDB dumps go code describing the contents of the database to stdout. This function is only intended for use during development.

Example output:

map[string]interface{}{
	hex("1234"): map[string]interface{}{
		"human-readable": hex("102030"),
		hex("1111"): hex("5783492373"),
	},
}

func Hex

func Hex(value string) string

Hex is a test helper function to convert readable hex arrays to raw byte strings.

func MakeDB

func MakeDB() (kvdb.Backend, func(), error)

MakeDB creates a new instance of the ChannelDB for testing purposes. A callback which cleans up the created temporary directories is also returned and intended to be executed after the test completes.

func RestoreDB

func RestoreDB(tx kvdb.RwTx, rootKey []byte, data map[string]interface{}) error

RestoreDB primes the database with the given data set.

func VerifyDB

func VerifyDB(tx kvdb.RTx, rootKey []byte, data map[string]interface{}) error

VerifyDB verifies the database against the given data set.

Types

This section is empty.

Jump to

Keyboard shortcuts

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