test

package
v11.3.3 Latest Latest
Warning

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

Go to latest
Published: Dec 13, 2022 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package test contains a backend acceptance test suite that is backend implementation independent each backend will use the suite to test itself

Index

Constants

This section is empty.

Variables

View Source
var (
	ErrMirrorNotSupported           = errors.New("mirror mode not supported")
	ErrConcurrentAccessNotSupported = errors.New("concurrent access not supported")
)

Functions

func AddItem

func AddItem(ctx context.Context, t *testing.T, uut backend.Backend, key []byte, value string, expires time.Time) (backend.Item, backend.Lease)

func MakePrefix

func MakePrefix() func(k string) []byte

MakePrefix returns function that appends unique prefix to any key, used to make test suite concurrent-run proof

func RequireItems

func RequireItems(t *testing.T, actual, expected []backend.Item)

RequireItems asserts that the supplied `actual` items collection matches the `expected` collection, in size, ordering and the key/value pairs of each entry.

func RunBackendComplianceSuite

func RunBackendComplianceSuite(t *testing.T, newBackend Constructor)

RunBackendComplianceSuite runs the entire backend compliance suite, creating a collection of named subtests under the context provided by `t`.

As each test requires a new backend instance it will invoke the supplied `newBackend` function, which callers will use inject instances of the backend under test.

Types

type ConstructionOption

type ConstructionOption func(*ConstructionOptions) error

ConstructionOption describes a named-parameter setting function for configuring a ConstructionOptions instance

func WithConcurrentBackend

func WithConcurrentBackend(target backend.Backend) ConstructionOption

WithConcurrentBackend() asks the constructor to create a

func WithMirrorMode

func WithMirrorMode(mirror bool) ConstructionOption

WithMirrorMode asks the constructor to create a Backend in "mirror mode". Not all backends will support this.

type ConstructionOptions

type ConstructionOptions struct {
	MirrorMode bool

	// ConcurrentBackend indicates that the Backend Constructor function should not
	// create an entirely independent data store, but instead should create a
	// new interface to the same underlying data store as `ConcurrentBackend`.
	ConcurrentBackend backend.Backend
}

func ApplyOptions

func ApplyOptions(options []ConstructionOption) (*ConstructionOptions, error)

ApplyOptions constructs a new `ConstructionOptions` value from a sensible default and then applies the supplied options to it.

func (*ConstructionOptions) Apply

func (opts *ConstructionOptions) Apply(options []ConstructionOption) error

Apply applies a collection of option-setting functions to the receiver, modifying it in-place.

type Constructor

type Constructor func(options ...ConstructionOption) (backend.Backend, clockwork.FakeClock, error)

Constructor describes a function for constructing new instances of a backend, with various options as required by a given test. Note that it's the caller's responsibility to close it when the test is finished.

Jump to

Keyboard shortcuts

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