blobtest

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Aug 7, 2026 License: Apache-2.0 Imports: 15 Imported by: 0

Documentation

Overview

Package blobtest is test support for the blob.Store seam: it starts one Dockerized MinIO per test binary and hands out per-test targets (endpoint, credentials, fresh bucket name) for backends to construct stores against. Production code must never import it. A missing Docker daemon is a hard failure, not a skip: skipped contract tests would silently hollow out the coverage gate (the pgtest rule).

Index

Constants

View Source
const (
	RootUser     = "blobtest"
	RootPassword = "blobtest-secret"
)

Root credentials for the throwaway container (MinIO requires a password of at least 8 characters).

View Source
const Image = "minio/minio:RELEASE.2025-09-07T16-13-09Z"

Image is the pinned MinIO the harness runs — the same release deploy/compose and the helm chart default to, so the contract tests exercise what ships.

Variables

This section is empty.

Functions

func Main

func Main(m *testing.M) int

Main wraps testing.M: it starts the shared MinIO container, runs the suite, and tears the container down. Use from TestMain: os.Exit(blobtest.Main(m)). The start is attempted twice, with a fresh container in between (#265; the retry's rationale is on pgtest.Main, whose rule this follows).

func Run

func Run(t *testing.T, newStore func(t *testing.T) blob.Store)

Run exercises the blob.Store contract (CLAUDE.md: every backend passes the same shared suite). newStore is called once per subtest so a backend can isolate its own fixtures — for the S3 backend, a fresh bucket per subtest. The suite asserts observable behavior only, never a backend's internals.

Types

type MemStore

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

MemStore is Mem's implementation. The concrete type is exported so tests can reach behind the API under test (Len, direct Delete) to assert storage side effects.

func Mem

func Mem() *MemStore

Mem returns an in-memory blob.Store for tests exercising logic above the storage seam (the API registry, later the executor's materialization). It holds the same contract as the real backends — the suite in contract.go runs against it in mem_test.go — without a MinIO container, so suites that already carry a Postgres harness need no second one.

func (*MemStore) Delete

func (s *MemStore) Delete(_ context.Context, key string) error

func (*MemStore) Get

func (s *MemStore) Get(_ context.Context, key string) (io.ReadCloser, int64, error)

func (*MemStore) Len

func (s *MemStore) Len() int

Len reports how many objects the store currently holds.

func (*MemStore) Put

func (s *MemStore) Put(_ context.Context, key string, r io.Reader, size int64, contentType string) error

type Target

type Target struct {
	Endpoint  string // host:port, plain HTTP
	AccessKey string
	SecretKey string
	Bucket    string
}

Target is one test's connection coordinates: the shared container's endpoint and credentials plus a bucket name no other test uses. The backend under test is expected to create the bucket itself.

func FreshTarget

func FreshTarget(t *testing.T) Target

FreshTarget returns the shared container's coordinates with a bucket name unique to this call.

Jump to

Keyboard shortcuts

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