conformance

package
v0.11.1 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 2026 License: MIT Imports: 11 Imported by: 0 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 conformance holds the tests every store of the module runs: the contract of the cache package, checked with identical expectations against a store built by the caller.

Usage

A store's tests call Run with a Subject that builds a new, uninitialized store with the DefaultTTL the suite asks for:

conformance.Run(t, conformance.Subject{
	Name: memory.ServiceName,
	New: func(t *testing.T, defaultTTL time.Duration) conformance.Store {
		cfg := memory.DefaultConfig()
		cfg.Cache.DefaultTTL = defaultTTL
		s, err := memory.New(memory.WithConfig(cfg))(nil, &gas.NopLogger{})
		require.NoError(t, err)
		return s
	},
})

A store that shares a server between tests gives each store a key space of its own, such as a key prefix unique to the test.

Suite

Run runs each rule as a parallel subtest, on a new store each: misses, a round trip, replacing, the empty key, keys of any bytes, copies in and out, nil and empty values, binary values, expiry, TTLs under a millisecond, negative TTLs, DefaultTTL, a zero TTL clearing a TTL, an ended context, the lifecycle sentinels and a restart, Init with an ended context, concurrent calls for -race, and errors that never quote a key. Every error is checked with errors.Is and its full text, which starts with the Subject's Name.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, s Subject)

Run runs the suite on s.

Types

type Store

type Store interface {
	gas.Service
	gas.CacheProvider
}

Store is a cache store with a lifecycle, as every store of the module is.

type Subject

type Subject struct {
	// New returns a new store, not initialized, whose DefaultTTL setting
	// is defaultTTL, holding no keys.
	New func(t *testing.T, defaultTTL time.Duration) Store
	// Name is the store's ServiceName, which starts its errors.
	Name string
}

Subject is a store under test.

Jump to

Keyboard shortcuts

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