testnet

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Nov 29, 2026 License: MIT Imports: 5 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

Overview

Package testnet provides an in-memory HTTP server for tests.

Connections are net.Pipe pairs, so goroutines blocked on them are durably blocked in the sense of testing/synctest, which is not the case for real sockets. Create the server inside the synctest bubble that uses it.

Go 1.27's httptest.NewTestServer offers the same; this package exists while the module still supports Go 1.26.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

Server is an HTTP server reachable only through its Client.

func New

func New(t testing.TB, handler http.Handler) *Server

New starts a server for handler and shuts it down when the test ends.

func (*Server) Client

func (s *Server) Client() *http.Client

Client returns a client whose every request goes to the server, whatever the URL's host.

Jump to

Keyboard shortcuts

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