testfault

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 4, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package testfault holds the failing fakes that handler tests share (decision 0015), so the error paths of streaming handlers are covered without real failures: a client that goes away mid-stream, and a blob store whose writes fail.

Index

Constants

This section is empty.

Variables

View Source
var ErrDisconnected = fmt.Errorf("testfault: client disconnected: %w", io.ErrUnexpectedEOF)

ErrDisconnected is what a Disconnect body fails with. It wraps io.ErrUnexpectedEOF, which net/http's body reports when the client closes the connection before the length it declared.

Functions

func Disconnect

func Disconnect(body io.Reader, n int64) io.Reader

Disconnect returns body cut off after n bytes: it reads as body does until it has given n bytes, then fails every read with ErrDisconnected, as a request body does when its client goes away mid-stream. A body shorter than n ends as it would.

Types

type Blobs

type Blobs struct {
	blob.Store
	Begin, Append, Commit error
}

Blobs is a blob store whose uploads fail: Begin fails BeginUpload, Append fails every Append once the upload has stored what it read, a write that fails part way through, and Commit fails Commit. A nil error passes the call to Store.

func (Blobs) BeginUpload

func (b Blobs) BeginUpload(ctx context.Context, opts ...blob.UploadOption) (blob.Upload, error)

BeginUpload starts an upload on Store whose Append and Commit fail as b says, or fails with Begin.

Jump to

Keyboard shortcuts

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