drivertest

package
v0.11.0 Latest Latest
Warning

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

Go to latest
Published: Jun 19, 2024 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package drivertest provides conformance tests for cache implementations.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConformanceTests

func RunConformanceTests(t *testing.T, newHarness HarnessMaker)

RunConformanceTests runs conformance tests for driver implementations of the cache.Cache interface.

Types

type Harness

type Harness interface {
	// MakeCache makes a [cache.Cache] for testing.
	MakeCache(context.Context) (cache.Cache, error)

	// Close closes resources used by the harness.
	Close()

	// Options returns the set of options that the cache supports.
	Options() Options
}

Harness descibes the functionality test harnesses must provide to run conformance tests.

type HarnessMaker

type HarnessMaker func(ctx context.Context, t *testing.T) (Harness, error)

HarnessMaker describes functions that construct a harness for running tests. It is called exactly once per test; Harness.Close() will be called when the test is complete.

type Options

type Options struct {
	// PatternMatchingDisabled is true if the cache does not support pattern matching.
	// If true, the cache does not support the following methods:
	//  - Count
	//  - DelKeys
	PatternMatchingDisabled bool

	// CloseIsNoop is true if the Close method is a no-op for the cache.
	// If true, the cache should still be usable after Close is called.
	CloseIsNoop bool
}

Options describes the set of options that a cache supports.

Jump to

Keyboard shortcuts

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