storagetest

package
v0.0.2 Latest Latest
Warning

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

Go to latest
Published: Oct 6, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Overview

Package storagetest is the conformance suite for jobsync Storage drivers. A driver is "official" when it passes Run with zero skips.

This exists because a prose contract is not a contract. The subtle parts of Storage — that Fetch is atomic across processes, that a late Finish from a server whose lease expired is ignored rather than applied, that a terminal job releases its unique key — are exactly the parts a new driver gets wrong, and exactly the parts that stay invisible until production. Each is a test here.

A driver's test file is three lines:

func TestConformance(t *testing.T) {
	storagetest.Run(t, func(t *testing.T) jobsync.Storage { return newTestStore(t) })
}

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DSN

func DSN(t *testing.T, env string) string

DSN returns the connection string for a driver's tests.

Unset locally it skips, naming the command that fixes it. Unset in CI it fails: a conformance suite that silently skips is worse than no suite, because it reports green while testing nothing. CI is detected by the CI environment variable, which GitHub Actions, GitLab and most others set.

func Run

func Run(t *testing.T, newStore New)

Run executes the whole conformance suite against newStore. Optional capabilities the driver does not implement are skipped, not failed.

func RunAPI

func RunAPI(t *testing.T, newStore New)

RunAPI exercises the dashboard's JSON API against a driver. It is separate from Run because it tests the HTTP layer rather than the Storage contract, but it runs against every driver for the same reason: the API is what the UI depends on, and a shape that differs between drivers becomes permanent the moment a page reads it.

Types

type New

type New func(t *testing.T) jobsync.Storage

New returns a storage with no jobs in it. It is called once per subtest and must clean up after itself via t.Cleanup.

Jump to

Keyboard shortcuts

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