fasttestutil

package
v0.5.6 Latest Latest
Warning

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

Go to latest
Published: Sep 5, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package fasttestutil is the fasthttp half of the backend-neutral test seam.

It declares Exchange with the name, the parameter order and the neutral request and response types testutil's has, so a test moves between the two by changing its import and nothing else — the same relationship pwfast has with pw, applied to the harness a test drives them through.

It is a package of its own rather than a file inside testutil because testutil is a shipped package that a net/http-only project imports, and putting the fasthttp fork behind that import would hand the fork to every such project.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Exchange

func Exchange(t pwtest.TestingT, handler fasthttp.RequestHandler, request pwtest.Request) pwtest.Response

Exchange runs one request through handler on a real fasthttp server and returns what it answered.

Real server, in-memory connection, the same as the other half: the request is parsed and the response serialized, so what is tested is what the transport does rather than what a hand-built request value was told to say.

Each call starts and keeps a server for the rest of the test; a test making several requests against one handler builds a Harness once instead.

Types

type Harness added in v0.5.2

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

Harness is one running server and one client, shared by every exchange of a test — the same shape as testutil.Harness, for the same reason: Exchange starts and keeps a server per call, so a test making N requests against one handler held N listeners and paid N startups.

func NewHarness added in v0.5.2

func NewHarness(t pwtest.TestingT, handler fasthttp.RequestHandler) *Harness

NewHarness starts a real fasthttp server for handler and returns the harness that drives it. The server is shut down by t.Cleanup.

func (*Harness) Exchange added in v0.5.2

func (h *Harness) Exchange(request pwtest.Request) pwtest.Response

Exchange runs one request through the harness's server and returns what it answered.

Jump to

Keyboard shortcuts

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