nettest

package
v1.84.3 Latest Latest
Warning

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

Go to latest
Published: Jun 26, 2025 License: BSD-3-Clause Imports: 11 Imported by: 0

Documentation

Overview

Package nettest contains additional test helpers related to network state that can't go into tstest for circular dependency reasons.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func GetNetwork added in v1.84.0

func GetNetwork(tb testing.TB) netx.Network

GetNetwork returns the appropriate Network implementation based on whether the --use-test-memnet flag is set.

Each call generates a new network.

func NewHTTPServer added in v1.84.0

func NewHTTPServer(net netx.Network, handler http.Handler) *httptest.Server

NewHTTPServer starts and returns a new httptest.Server. The caller should call Close when finished, to shut it down.

func NewUnstartedHTTPServer added in v1.84.0

func NewUnstartedHTTPServer(nw netx.Network, handler http.Handler) *httptest.Server

NewUnstartedHTTPServer returns a new httptest.Server but doesn't start it.

After changing its configuration, the caller should call Start or StartTLS.

The caller should call Close when finished, to shut it down.

func PreferMemNetwork added in v1.84.0

func PreferMemNetwork() bool

PreferMemNetwork reports whether the --use-test-memnet flag is set.

func SkipIfNoNetwork

func SkipIfNoNetwork(t testing.TB)

SkipIfNoNetwork skips the test if it looks like there's no network access.

Types

This section is empty.

Jump to

Keyboard shortcuts

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