conformance

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 18, 2026 License: Apache-2.0 Imports: 5 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 conformance provides the test suite every coordination.Backend implementation must pass.

Call Run from a test of the implementation's package:

func TestBackend(t *testing.T) {
	conformance.Run(t, func(t *testing.T) (coordination.Backend, func(time.Duration)) {
		clock := newManualClock()
		return newBackend(clock), clock.Advance
	})
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Run

func Run(t *testing.T, factory Factory)

Run verifies the lease contract of the backends produced by factory, one subtest per property: immediate contention returns coordination.ErrNotAcquired; a waiting acquisition honours cancellation; renewal extends the deadline from the current time; release and expiry close Done; a released lease cannot be renewed after another owner acquires the key (coordination.ErrLeaseLost); and fencing tokens strictly increase across release and expiry. Each subtest waits at most one second of real time for asynchronous effects.

Example

Backend authors call Run from a test in their package, returning a fresh backend and a hook that advances its clock.

_ = func(t *testing.T) {
	conformance.Run(t, func(t *testing.T) (coordination.Backend, func(time.Duration)) {
		clock := newFakeClock(time.Unix(0, 0))
		return memory.NewBackend(clock), clock.Advance
	})
}

Types

type Factory

type Factory func(t *testing.T) (coordination.Backend, func(time.Duration))

Factory returns a fresh, empty backend for one subtest together with a hook that advances the backend's clock by the given duration and delivers the timers that become due. Register cleanup with t.Cleanup.

Jump to

Keyboard shortcuts

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