s3test

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Nov 26, 2026 License: Apache-2.0 Imports: 15 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 s3test is an in-process fake of the S3 API for tests: one bucket, objects in memory, SigV4 signatures checked on every request, multipart uploads, ranged reads, ListObjects (v1) and injected failures. It speaks path style and virtual-host style (bucket.HOST).

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	*httptest.Server
	Bucket string
	Region string
	Creds  blob.Credentials
	// contains filtered or unexported fields
}

Server is a running fake.

func New

func New(t testing.TB) *Server

New starts a fake with bucket "vx-test" and test credentials; it stops when the test ends.

func (*Server) BucketURL

func (s *Server) BucketURL(prefix string) string

BucketURL is the vx bucket URL for this fake with prefix, e.g. s3://vx-test/prefix?endpoint=http://127.0.0.1:PORT.

func (*Server) Count

func (s *Server) Count(method string) int

Count returns how many requests of a method arrived (after failures).

func (*Server) CutNextBodies

func (s *Server) CutNextBodies(n int)

CutNextBodies makes the next n GET responses stop after half the body, as a broken connection would.

func (*Server) Env

func (s *Server) Env(prefix string) func(string) string

Env returns a getenv for blob.OpenOptions with the fake's credentials under the prefix (VX_BLOB by default).

func (*Server) FailNext

func (s *Server) FailNext(statuses ...int)

FailNext answers the next len(statuses) requests with those statuses.

func (*Server) Keys

func (s *Server) Keys() []string

Keys lists stored keys, sorted.

func (*Server) Object

func (s *Server) Object(key string) ([]byte, bool)

Object returns a stored object's bytes.

func (*Server) OpenUploads

func (s *Server) OpenUploads() int

OpenUploads is how many multipart uploads were started and neither completed nor aborted.

func (*Server) SetModified

func (s *Server) SetModified(key string, t time.Time)

SetModified changes when an object was last written, for retention tests.

func (*Server) SetObject

func (s *Server) SetObject(key string, b []byte)

SetObject stores bytes directly, for corruption tests.

Jump to

Keyboard shortcuts

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