contracttest

package
v0.10.2 Latest Latest
Warning

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

Go to latest
Published: May 5, 2026 License: MIT Imports: 8 Imported by: 0

Documentation

Overview

Package contracttest provides a shared test suite that validates the blobcache.Store contract. Backend authors (diskblob, future s3blob, gcsblob, etc.) call RunStoreContractTests with a factory that returns a fresh, empty Store rooted at a temp location; the suite then exercises the contractually required behavior — round-trip, ETag determinism, namespace isolation, concurrent put on the same key, list-after-delete, and traversal rejection.

The suite is intentionally factory-based so backends with non-trivial setup (S3 buckets, GCS prefixes, redis prefixes) can plug in their own teardown hook via the test's t.Cleanup.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunStoreContractTests

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

RunStoreContractTests exercises every contractual guarantee of blobcache.Store. Call this from a backend's _test.go:

func TestStoreContract(t *testing.T) {
    contracttest.RunStoreContractTests(t, func(t *testing.T) blobcache.Store {
        return fsstore.New(t.TempDir())
    })
}

Each contract assertion lives in its own helper to keep cyclomatic complexity low and make individual assertions easy to skip / extend in downstream backends. Add new assertions by appending another helper here and a corresponding t.Run line below.

Types

type StoreFactory

type StoreFactory func(t *testing.T) blobcache.Store

StoreFactory returns a freshly initialized, empty blobcache.Store for the duration of a single subtest. Implementations should register cleanup hooks via t.Cleanup so each subtest starts from a clean state.

Jump to

Keyboard shortcuts

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