backendtest

package
v0.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package backendtest is the parameterized interface-conformance test for container.Backend. It exercises ONLY what every Backend impl is contractually obliged to do (Capabilities returns a known mode; Create→Destroy lifecycle; Snapshot/Restore route ErrUnsupported when Caps says "none"; double-Destroy errors per the io.Closer convention).

Backend-specific behavior tests (scripted Exec for the fake, real shell execution for Docker, fault hooks for the fake) live in each backend's own *_test.go file. Phase 2 has one Backend — building a Factory + callback machinery here would be the speculative abstraction CLAUDE.md forbids ("no speculative interfaces, registries, or plugin layers"). When Phase 4's Docker impl exists, we'll learn which abstraction shape actually pays.

Pattern: Go stdlib testing/fstest. Used both by Phase 2's fake (slice 2.2) and Phase 4's Docker impl unchanged.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func RunBasicContract

func RunBasicContract(t *testing.T, b container.Backend)

RunBasicContract verifies that b honors the container.Backend interface contract. Caller passes a configured Backend instance; the helper does the rest. Each sub-test takes b as-is — for tests that need a clean slate, the caller can re-create the backend before each RunBasicContract call.

func RunCopyToContract

func RunCopyToContract(t *testing.T, b container.Backend)

RunCopyToContract verifies CopyTo stages bytes that a subsequent CaptureFiles reads back (the artifact round-trip). Uses a NESTED destination path so the Docker impl exercises parent-directory creation. Caller passes a configured Backend; the helper Creates/Destroys its own container.

func RunReadWriteFileAtContract added in v0.1.1

func RunReadWriteFileAtContract(t *testing.T, b container.Backend)

RunReadWriteFileAtContract verifies WriteFileAt → ReadFileAt round-trips and that a cancelled context errors. Backends without a real impl (docker/native stubs) should not be passed here yet.

func RunSnapshotContract

func RunSnapshotContract(t *testing.T, b container.Backend, image, name string)

RunSnapshotContract verifies that b honors the Snapshot+Restore round-trip contract for backends advertising SnapshotFSCoW. Skipped on SnapshotNone backends — their behavior is covered by RunBasicContract's testSnapshotRouting sub-test.

  • image: the digest-pinned reference Create will use.
  • name: the IR-declared container name (passed to Restore per slice 4.4 Design Q9).

Three sub-tests align with Phase 4 design decision 12 (Bucket 11):

  • WorkspaceMutationCapturedAndRestored (11a)
  • DeletedFileRestoredAsDeleted (11b)
  • SmallWorkspaceDoesNotTripDefaultCap (smoke; the real cap-trip assertion is Docker integ TestBucket11c via WithSnapshotMaxBlobBytes).

Types

This section is empty.

Jump to

Keyboard shortcuts

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