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 ¶
- Variables
- type Objects
- func (o *Objects) Check(context.Context) error
- func (o *Objects) Cleanup(ctx context.Context, key string) error
- func (o *Objects) Delete(_ context.Context, key string) error
- func (o *Objects) DeletePrefix(_ context.Context, prefix string) (int, error)
- func (o *Objects) Get(_ context.Context, key string) (io.ReadCloser, int64, error)
- func (o *Objects) Has(key string) bool
- func (o *Objects) Incomplete() []string
- func (o *Objects) Keys() []string
- func (o *Objects) Lifecycle(context.Context) (uploads.LifecycleCoverage, error)
- func (o *Objects) Put(ctx context.Context, key string, r io.Reader, size int64, ct string) error
- func (o *Objects) Seed(key string, data []byte)
- func (o *Objects) Stat(_ context.Context, key string) (int64, error)
- type Store
- func (s *Store) Create(ctx context.Context, u uploads.Upload) (uploads.Upload, error)
- func (s *Store) Get(ctx context.Context, id string) (uploads.Upload, error)
- func (s *Store) LinkTarget(_ context.Context, id string) (uploads.Upload, error)
- func (s *Store) Revoke(ctx context.Context, id string) (uploads.Upload, error)
- func (s *Store) Rows() []uploads.Upload
Constants ¶
This section is empty.
Variables ¶
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
// FailDelete, when set, fails every Delete and DeletePrefix.
FailDelete error
// AfterDeletePrefix, when set, runs at the end of every DeletePrefix: a
// test's hook into the moment after a page's prefix is swept.
AfterDeletePrefix func()
// contains filtered or unexported fields
}
Objects is uploads.ObjectStore in memory.
func (*Objects) DeletePrefix ¶ added in v0.205.0
DeletePrefix deletes every stored key under prefix, then runs AfterDeletePrefix (with no lock held), if set.
func (*Objects) Incomplete ¶
Incomplete lists the keys with a multipart upload initiated and neither completed nor aborted — what a failed write orphans.
func (*Objects) Put ¶
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.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is uploads.Store in memory.
func (*Store) LinkTarget ¶
LinkTarget is any owner's row.