Help us shape the future of Go! Take the 2026 Go Developer Survey

fixtures

package
v0.189.0 Latest Latest
Warning

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

Go to latest
Published: Oct 19, 2026 License: Apache-2.0 Imports: 12 Imported by: 0

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