uploadstest

package
v0.119.0 Latest Latest
Warning

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

Go to latest
Published: Oct 31, 2026 License: MIT Imports: 8 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package uploadstest is in-memory fakes of internal/uploads' two ports — the row store and the object store — for tests that drive the upload routes without Postgres or an S3 server. The Postgres store's own behaviour (row-level security included) is tested against Postgres in internal/uploads; these fakes model only its OWNER SCOPING, from the context's principal, so a route test can tell one user from another.

Index

Constants

This section is empty.

Variables

View Source
var AbortLatency = 20 * time.Millisecond

AbortLatency is how long the fake's AbortMultipartUpload "round trip" takes. minio-go aborts a failed multipart write under the SAME context the write ran under; if that context is cancelled meanwhile — a request whose client went away — the abort never arrives and the parts stay.

Functions

This section is empty.

Types

type Objects

type Objects struct {

	// Types is the Content-Type each object was stored with, and Sizes the
	// size Put was told (-1: streamed with no length).
	Types map[string]string
	Sizes map[string]int64
	// Gets and Stats count the calls of each.
	Gets, Stats int
	// Coverage and RulesErr are what Lifecycle answers.
	Coverage uploads.LifecycleCoverage
	RulesErr error
	// SkipAbort makes a failed multipart Put leave its upload behind even with
	// a live context (the store's own abort request failed); FailCleanup is
	// what Cleanup answers. Each lets a test pin ONE of the two layers that
	// remove a failed write.
	SkipAbort   bool
	FailCleanup error

	// FailPut, when set, is what Put answers.
	FailPut error
	// contains filtered or unexported fields
}

Objects is uploads.ObjectStore in memory.

func (*Objects) Check

func (o *Objects) Check(context.Context) error

Check always answers.

func (*Objects) Cleanup

func (o *Objects) Cleanup(ctx context.Context, key string) error

Cleanup aborts key's incomplete uploads and deletes key, under ctx.

func (*Objects) Delete

func (o *Objects) Delete(_ context.Context, key string) error

Delete removes an object.

func (*Objects) Get

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

Get opens a stored object.

func (*Objects) Has

func (o *Objects) Has(key string) bool

Has reports whether key is stored.

func (*Objects) Incomplete

func (o *Objects) Incomplete() []string

Incomplete lists the keys with a multipart upload initiated and neither completed nor aborted — what a failed write orphans.

func (*Objects) Keys

func (o *Objects) Keys() []string

Keys is every stored key.

func (*Objects) Lifecycle

Lifecycle answers Coverage, or RulesErr.

func (*Objects) Put

func (o *Objects) Put(ctx context.Context, key string, r io.Reader, size int64, ct string) error

Put stores what it reads from r. A known size is ONE request; an unknown size (-1) is a MULTIPART upload, modelled as a real store keeps one: it is initiated, each uploads.PartSize part is sent under ctx, and it stays listed (Incomplete) until it is completed or aborted. A failure aborts it only if ctx survives the abort's round trip.

func (*Objects) Stat

func (o *Objects) Stat(_ context.Context, key string) (int64, error)

Stat is a stored object's length, without reading it.

type Store

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

Store is uploads.Store in memory.

func (*Store) Create

func (s *Store) Create(ctx context.Context, u uploads.Upload) (uploads.Upload, error)

Create stores u as the context principal's.

func (*Store) Get

func (s *Store) Get(ctx context.Context, id string) (uploads.Upload, error)

Get is the principal's row.

func (*Store) LinkTarget

func (s *Store) LinkTarget(_ context.Context, id string) (uploads.Upload, error)

LinkTarget is any owner's row.

func (*Store) Revoke

func (s *Store) Revoke(ctx context.Context, id string) (uploads.Upload, error)

Revoke marks the principal's row revoked.

func (*Store) Rows

func (s *Store) Rows() []uploads.Upload

Rows is every stored row (a copy).

Jump to

Keyboard shortcuts

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