storetest

package
v0.9.21 Latest Latest
Warning

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

Go to latest
Published: Jul 21, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package storetest provides a reusable conformance suite for checkpoint.Store implementations, in the style of workqueue/conformance. Every Store (memstore, jsonlstore, and the future GCS store) is expected to pass RunConformance.

The suite exercises the full Store contract: Load-miss behavior, Save/Load round-trips (byte-for-byte, deep-copied), claim-once Delete via CAS tokens, token mismatch on stale or absent tokens, and re-save invalidating an old token.

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunConformance

func RunConformance(t *testing.T, newStore func() checkpoint.Store)

RunConformance exercises the Store contract: Load-miss, Save/Load round-trip, claim-once Delete, token-mismatch on stale/absent tokens, and re-save invalidating an old token. newStore must return a fresh, empty Store on each call.

Example

ExampleRunConformance demonstrates the constructor shape RunConformance expects. The suite itself needs a *testing.T, so a Store package wires it into a regular test:

func TestConformance(t *testing.T) {
	storetest.RunConformance(t, func() checkpoint.Store {
		return memstore.New()
	})
}
package main

import (
	"fmt"

	"chainguard.dev/driftlessaf/agents/checkpoint"
	"chainguard.dev/driftlessaf/agents/checkpoint/memstore"
	"chainguard.dev/driftlessaf/agents/checkpoint/storetest"
)

func main() {
	// RunConformance calls the constructor once per subtest; each call must
	// return a fresh, empty Store.
	newStore := func() checkpoint.Store { return memstore.New() }

	// The suite entry point only executes under a *testing.T (see above).
	suite := storetest.RunConformance
	fmt.Println("suite wired:", suite != nil)
	fmt.Println("fresh store ready:", newStore() != nil)
}
Output:
suite wired: true
fresh store ready: true

Types

This section is empty.

Jump to

Keyboard shortcuts

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