idempotencytest

package
v1.0.0 Latest Latest
Warning

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

Go to latest
Published: Aug 26, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package idempotencytest provides reusable adapter conformance and fixtures.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStoreConformance

func RunStoreConformance(t *testing.T, factory StoreFactory)

RunStoreConformance proves shared ownership, fencing, and replay behavior.

Types

type Clock

type Clock struct {
	// contains filtered or unexported fields
}

Clock is a concurrency-safe deterministic clock for store tests.

func NewClock

func NewClock(now time.Time) *Clock

NewClock constructs a deterministic clock at now.

func (*Clock) Advance

func (c *Clock) Advance(duration time.Duration)

Advance moves the clock forward by duration.

func (*Clock) Now

func (c *Clock) Now() time.Time

Now returns the current deterministic instant.

func (*Clock) Set

func (c *Clock) Set(now time.Time)

Set replaces the current deterministic instant.

type StoreFactory

type StoreFactory func(testing.TB) StoreFixture

StoreFactory constructs a fresh fixture for one conformance subtest.

type StoreFixture

type StoreFixture struct {
	// Store is the backend instance under test.
	Store idempotency.Store
	// Key identifies the shared operation used by the conformance cases.
	Key idempotency.Key
	// Fingerprint identifies the shared business request used by the cases.
	Fingerprint idempotency.Fingerprint
	// Advance moves authoritative backend time when the fixture supports it.
	Advance func(time.Duration)
}

StoreFixture supplies an isolated backend and deterministic identities.

type TokenSource

type TokenSource struct {
	// contains filtered or unexported fields
}

TokenSource emits deterministic unique ownership tokens for tests.

func NewTokenSource

func NewTokenSource(prefix string) *TokenSource

NewTokenSource constructs a token source using prefix.

func (*TokenSource) Next

func (s *TokenSource) Next() (string, error)

Next returns the next deterministic token.

Jump to

Keyboard shortcuts

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