fixtures

package
v0.203.0 Latest Latest
Warning

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

Go to latest
Published: Nov 24, 2026 License: Apache-2.0 Imports: 12 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

Index

Constants

This section is empty.

Variables

View Source
var Failures = SliceTransport{
	{
		MatchAny:     true,
		ReuseRequest: true,
		Status:       418,
		Response:     `{"error_code": "NONSENSE", "message": "I'm a teapot"}`,
	},
}

Functions

This section is empty.

Types

type HTTPFixture

type HTTPFixture struct {
	Method       string
	Resource     string
	MatchAny     bool
	ReuseRequest bool

	Response        any
	Status          int
	ResponseHeaders map[string][]string
	ExpectedRequest any
	ExpectedHeaders map[string]string
	PassFile        string
}

HTTPFixture defines request structure for test

func (HTTPFixture) AssertHeaders added in v0.26.2

func (f HTTPFixture) AssertHeaders(req *http.Request) error

func (HTTPFixture) AssertRequest

func (f HTTPFixture) AssertRequest(req *http.Request) error

func (HTTPFixture) Match

func (f HTTPFixture) Match(method, resource string) bool

func (HTTPFixture) Reply

func (f HTTPFixture) Reply(req *http.Request) (*http.Response, error)

type MappingTransport

type MappingTransport map[string]HTTPFixture

MappingTransport stubs are 2 lines shorter than SliceTransport

func (MappingTransport) RoundTrip

func (fixtures MappingTransport) RoundTrip(req *http.Request) (*http.Response, error)

func (MappingTransport) SkipRetryOnIO

func (fixtures MappingTransport) SkipRetryOnIO() bool

type SliceTransport

type SliceTransport []HTTPFixture

func (SliceTransport) RoundTrip

func (fixtures SliceTransport) RoundTrip(req *http.Request) (*http.Response, error)

func (SliceTransport) SkipRetryOnIO

func (fixtures SliceTransport) SkipRetryOnIO() bool

Jump to

Keyboard shortcuts

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