testhelpers

package
v0.0.0-...-12e3ab2 Latest Latest
Warning

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

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

Documentation

Overview

Package testhelpers provides testing utilities for mocking HTTP requests and responses.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MockNetworkError

func MockNetworkError() (*http.Response, error)

MockNetworkError simulates network failure

func MockStatusResponse

func MockStatusResponse(status int) (*http.Response, error)

MockStatusResponse returns custom status code

func MockSuccessResponse

func MockSuccessResponse(body []byte) (*http.Response, error)

MockSuccessResponse returns 200 OK with body

func MockTimeoutError

func MockTimeoutError() (*http.Response, error)

MockTimeoutError simulates timeout

func NewMockHTTPClient

func NewMockHTTPClient(responseFunc func(*http.Request) (*http.Response, error)) *http.Client

NewMockHTTPClient creates http.Client with mock transport

Types

type MockRoundTripper

type MockRoundTripper struct {
	ResponseFunc func(*http.Request) (*http.Response, error)
}

MockRoundTripper intercepts HTTP requests and returns mock responses

func (*MockRoundTripper) RoundTrip

func (m *MockRoundTripper) RoundTrip(req *http.Request) (*http.Response, error)

Jump to

Keyboard shortcuts

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