Help us shape the future of Go! Take the 2026 Go Developer Survey

blobtest

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package blobtest is test support for the blob.Store seam: it starts one Dockerized Silo (a MinIO fork, see Image) 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 (the server requires a password of at least 8 characters).

View Source
const Image = "pgsty/silo:RELEASE.2026-09-16T00-00-00Z@sha256:635197cb9f36d01bee221d34d1c7d7960f6a95c48b0b6c01d99cd13bdae51a46"

Image is the pinned object store the harness runs — the same image deploy/compose and the helm chart default to, so the contract tests exercise what ships; pins_test.go fails when one of the three moves without the others.

It is PGSTY Silo, a maintained fork of the MinIO server, not MinIO itself, and every one of those three pins changed for the same reason: MinIO took its community images off both registries it had published them to. Docker Hub stopped serving the `minio` namespace between 2026-09-11 and 2026-09-12 (#701), and quay.io, which the pins moved to then, began refusing `minio/minio` with a 401 on 2026-09-24 (#799) — each time a hard failure on any machine without the image already cached. Silo keeps the server's wire and operator surface, which is what the three pins depend on: the S3 API, the MINIO_ROOT_* variables, the /minio/health/* routes, `server /data` as the container's arguments, and `mc` in the image. The digest pins the bytes as well as the release: the image comes from one third-party publisher, and a re-pushed tag would otherwise change the server every fresh machine pulls, unnoticed.

Variables

This section is empty.

Functions

func Main

func Main(m *testing.M) int

Main wraps testing.M: it starts the shared Silo 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). It opens by reaping what an earlier killed run left behind, the defer below being unreachable to one (#346; the rationale is in dockertest).

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 Silo 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