testutil

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Jul 9, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockAPIHandler

func MockAPIHandler() http.Handler

MockAPIHandler creates a mock API handler for testing

func NewTestHTTPClient

func NewTestHTTPClient(handler http.Handler) *http.Client

NewTestHTTPClient creates an HTTP client for testing with a mock server

func NewTestIOStreams

func NewTestIOStreams() (*iostreams.IOStreams, *bytes.Buffer, *bytes.Buffer, *bytes.Buffer)

NewTestIOStreams creates IOStreams for testing

func SetTestToken

func SetTestToken() func()

SetTestToken sets test environment token

Types

type RoundTripFunc added in v0.7.0

type RoundTripFunc func(*http.Request) (*http.Response, error)

RoundTripFunc is an http.RoundTripper implemented by a function. It allows tests to mock HTTP transport without a real server.

func NewRoundTripFunc added in v0.7.0

func NewRoundTripFunc(fn func(*http.Request) (*http.Response, error)) RoundTripFunc

NewRoundTripFunc wraps fn in a RoundTripFunc for use as an http.RoundTripper.

func (RoundTripFunc) RoundTrip added in v0.7.0

func (fn RoundTripFunc) RoundTrip(req *http.Request) (*http.Response, error)

RoundTrip implements http.RoundTripper by calling the underlying function.

Source Files

  • roundtrip.go
  • testutil.go

Jump to

Keyboard shortcuts

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