bs3test

package
v0.20260921.0 Latest Latest
Warning

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

Go to latest
Published: Sep 17, 2026 License: MPL-2.0 Imports: 11 Imported by: 0

Documentation

Overview

Package bs3test provides an in-memory fake of the S3 client subset provided by the bs3 package, for use in tests.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type FakeS3

type FakeS3 struct {
	Objects map[string]StoredObject
	// contains filtered or unexported fields
}

FakeS3 implements the PutObject/GetObject/Bucket subset of the S3 API with an in-memory map.

func New

func New() *FakeS3

func (*FakeS3) Bucket

func (f *FakeS3) Bucket() string

Bucket returns a fixed bucket name, "fakebucket".

func (*FakeS3) GetObject

func (f *FakeS3) GetObject(ctx context.Context, params *s3.GetObjectInput, optFns ...func(*s3.Options)) (*s3.GetObjectOutput, error)

GetObject returns the object stored under params.Key, failing with 404 Not Found when there is none.

func (*FakeS3) PutObject

func (f *FakeS3) PutObject(ctx context.Context, params *s3.PutObjectInput, optFns ...func(*s3.Options)) (*s3.PutObjectOutput, error)

PutObject stores params.Body under params.Key. It fails with 412 Precondition Failed when params.IfNoneMatch is set and the key exists, or when params.IfMatch is set and does not match the stored ETag, and with 404 Not Found when params.IfMatch is set and the key does not exist.

type StoredObject

type StoredObject struct {
	Data            []byte
	ContentEncoding *string
	// ETag is set by PutObject. An object placed in Objects directly without
	// one has no ETag, so GetObject returns none and IfMatch never matches it.
	ETag string
}

StoredObject is an object held by a FakeS3.

Jump to

Keyboard shortcuts

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