archivetest

package
v0.15.0 Latest Latest
Warning

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

Go to latest
Published: Nov 25, 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 archivetest provides an in-memory archive.Store for tests of the packages that archive runs or serve archived objects.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Object

type Object struct {
	Body        []byte
	ContentType string
}

Object is one stored object.

type Store

type Store struct {

	// PutErr, when set, is returned by every Put before anything is stored,
	// simulating an unreachable bucket.
	PutErr error
	// Now tells time for presign expiry; nil means time.Now.
	Now func() time.Time
	// contains filtered or unexported fields
}

Store is an in-memory archive.Store with the real create-only semantics. The zero value is not usable; call New.

func New

func New() *Store

New returns an empty store.

func (*Store) Close

func (s *Store) Close() error

Close does nothing.

func (*Store) Get

func (s *Store) Get(_ context.Context, key string) (io.ReadCloser, error)

Get opens a stored object.

func (*Store) Keys

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

Keys lists stored keys in first-write order.

func (*Store) Object

func (s *Store) Object(key string) (Object, bool)

Object returns a stored object and whether it exists.

func (*Store) Presign

func (s *Store) Presign(
	_ context.Context, key string, ttl time.Duration, attachment string,
) (string, time.Time, error)

Presign returns a fake https URL naming the key, the expiry and the attachment name, so tests can assert on all three.

func (*Store) Put

func (s *Store) Put(_ context.Context, key string, body []byte, contentType string) error

Put stores body at key once; the same bytes again succeed and different bytes fail with archive.ErrConflict.

func (*Store) Puts

func (s *Store) Puts() []string

Puts lists every Put attempt's key in order, retries included.

Jump to

Keyboard shortcuts

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