dbtest

package
v0.2.3 Latest Latest
Warning

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

Go to latest
Published: Jan 30, 2022 License: MIT Imports: 8 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, dbFn func(kvs []*VersionedKV, clock Clock) (DB, error))

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

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, dbFn func(kvs []*VersionedKV) (DB, error))

TestHistory tests the History function. dbFn must return a DB under test with the VersionedKV's stored in the database.

func TestList

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

TestList tests the List function. dbFn must return a DB under test with the VersionedKV's stored in the database.

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.

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.

Jump to

Keyboard shortcuts

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