drivertest

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Jul 25, 2024 License: Apache-2.0 Imports: 9 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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[K driver.String](t *testing.T, newHarness HarnessMaker[K, *testing.T])

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

Types

type Harness

type Harness[K driver.String] interface {
	// MakeCache makes a [driver.Cache] for testing.
	MakeCache(context.Context) (driver.Cache[K], 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[K driver.String, TB testing.TB] func(ctx context.Context, t TB) (Harness[K], 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