dbtest

package
v0.2.5 Latest Latest
Warning

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

Go to latest
Published: Feb 7, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Overview

Package dbtest contains tests for DBs. Implementation under test is pluggable.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func TestDelete

func TestDelete(t *testing.T, oldValue, newValue Value, dbFn func(kvs []*VersionedKV, clock Clock) (db DB,
	closeFn func(), err error))

TestDelete tests the Delete function. dbFn must return a DB under test with the VersionedKV's stored in the database and set transaction times provided by the clock. It must also return a function to close the DB after the test is complete.

func TestGet

func TestGet(t *testing.T, oldValue, newValue Value, dbFn func(kvs []*VersionedKV) (db DB, closeFn func(), err error))

TestGet tests the Get function. dbFn must return a DB under test with the VersionedKV's stored in the database and a function to close the DB after the test is complete.

func TestHistory

func TestHistory(t *testing.T, oldValue, newValue Value, dbFn func(kvs []*VersionedKV) (db DB, closeFn func(), err error))

TestHistory tests the History function. dbFn must return a DB under test with the VersionedKV's stored in the database and a function to close the DB after the test is complete.

func TestList

func TestList(t *testing.T, oldValue, newValue Value, dbFn func(kvs []*VersionedKV) (db DB, closeFn func(), err error))

TestList tests the List function. dbFn must return a DB under test with the VersionedKV's stored in the database and a function to close the DB after the test is complete.

func TestSet

func TestSet(t *testing.T, dbFn func(kvs []*VersionedKV, clock Clock) (DB, error))

TestSet tests the Set function. dbFn must return a DB under test with the VersionedKV's stored in the database and transaction times provided by the clock.

func WriteOutputHistory added in v0.2.4

func WriteOutputHistory(t *testing.T, db DB, keys []string, testName string)

WriteOutputHistory writes to a file the final "history" for specified keys at the end of a test. This is used for debugging and visualization.

Types

type TestClock

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

TestClock is a clock returns user-set times for testing. It enforces that new times being set must be monotonically increasing as a safeguard for correct tests.

func (*TestClock) Now

func (c *TestClock) Now() time.Time

Now returns user-set time for testing

func (*TestClock) SetNow

func (c *TestClock) SetNow(t time.Time) error

SetNow sets "now" returned by the DB for transaction times. Times being set must be monotonically increasing.

type TestOutput added in v0.2.4

type TestOutput struct {
	TestName  string
	Passed    bool                      // true is test passed
	Histories map[string][]*VersionedKV // key -> history
}

TestOutput is the format for saving test data for debugging and visualization.

Jump to

Keyboard shortcuts

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