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 ¶
- Variables
- func AddItem(ctx context.Context, t *testing.T, uut backend.Backend, key []byte, ...) (backend.Item, backend.Lease)
- func MakePrefix() func(k string) []byte
- func RequireItems(t *testing.T, actual, expected []backend.Item)
- func RunBackendComplianceSuite(t *testing.T, newBackend Constructor)
- type ConstructionOption
- type ConstructionOptions
- type Constructor
Constants ¶
This section is empty.
Variables ¶
var ( ErrMirrorNotSupported = errors.New("mirror mode not supported") ErrConcurrentAccessNotSupported = errors.New("concurrent access not supported") )
Functions ¶
func MakePrefix ¶
MakePrefix returns function that appends unique prefix to any key, used to make test suite concurrent-run proof
func RequireItems ¶
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 ¶
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.