testutil

package
v0.0.0-...-506f5f6 Latest Latest
Warning

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

Go to latest
Published: Sep 18, 2026 License: Apache-2.0 Imports: 34 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	Alice                = testutil.Alice
	Bob                  = testutil.Bob
	Carol                = testutil.Carol
	Mallory              = testutil.Mallory
	Service              = testutil.Service
	WebService           = identity.Identity{Issuer: testutil.WebService}
	WebServiceSigner     = testutil.WebServiceSigner
	RandomBytes          = testutil.RandomBytes
	RandomDID            = testutil.RandomDID
	RandomMultihash      = testutil.RandomMultihash
	RandomIssuer         = testutil.RandomIssuer
	RandomMultikeyIssuer = testutil.RandomMultikeyIssuer
)

Functions

func CreatePostgres

func CreatePostgres(t *testing.T) *pgxpool.Pool

CreatePostgres starts a throwaway Postgres container, runs the sprue migrations against it, and returns a connection pool. The container is cleaned up when the test finishes.

func CreateS3

func CreateS3(t *testing.T) *url.URL

func DeriveBlobProvider

func DeriveBlobProvider(t *testing.T, digest multihash.Multihash) ucan.Issuer

DeriveBlobProvider mirrors the production handler's logic for deriving a signer from a blob's digest, used to sign /http/put invocations and receipts.

func IsDockerAvailable

func IsDockerAvailable(t testing.TB) bool

IsDockerAvailable returns true if the docker daemon is available, useful for skipping tests when docker isn't running

func IsRunningInCI

func IsRunningInCI(t testing.TB) bool

IsRunningInCI returns true of process is running in CI environment.

func Must

func Must[T any](val T, err error) func(*testing.T) T

func NewMockPiriServer

func NewMockPiriServer(
	t *testing.T,
	storageProvider ucan.Issuer,
	uploadService identity.Identity,
	allocateOK *blobcmds.AllocateOK,
	acceptOK *blobcmds.AcceptOK,
) *httptest.Server

NewMockPiriServer stands up a UCAN HTTP server that handles /blob/allocate & /blob/accept by returning the canned responses. Wraps the upload service's did:web identity so signatures verify against the underlying did:key.

func NewS3Client

func NewS3Client(t *testing.T, endpoint *url.URL) *s3.Client

func ProviderProofs

func ProviderProofs(t *testing.T, storageProvider, uploadService ucan.Issuer) ucan.Container

ProviderProofs builds the proof container a storage provider grants the upload service at registration: self-issued delegations (subject = provider) authorizing `/blob/allocate` and `/blob/accept`.

func RandomCID

func RandomCID(t *testing.T) cid.Cid

Types

This section is empty.

Jump to

Keyboard shortcuts

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