httpservertest

package
v2.0.0-dev.12 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 29 Imported by: 0

Documentation

Overview

Package httpservertest holds the test helpers for code built on httpserver. It sits apart from httpserver so that package imports no testing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CheckCodeSpecs

func CheckCodeSpecs(t testing.TB, dir string, specs map[httpserver.ErrorCode]httpserver.CodeSpec)

CheckCodeSpecs fails t unless specs holds exactly the codes the package in dir writes, naming each missing from specs and each key nothing writes. It type-checks dir's non-test files as go build selects them, so the package must compile. A code is a string constant expression passed as an ErrorCode argument to WriteError, NewErrorResponse, a function the package declares or a func value, or set in an ErrorCode field of any struct literal, or listed in an ErrorCode slice or array a struct field holds; another package's functions do not write, and neither does a map key.

func CheckNoUI

func CheckNoUI(t testing.TB, h http.Handler)

CheckNoUI fails t unless h answers every path and method with not_found (404) as the error envelope: the root of a build with no web UI.

func CheckSPA

func CheckSPA(t testing.TB, h http.Handler, c httpserver.SPAConfig)

CheckSPA fails t unless h, httpserver.SPA built from c (alone or at "/" of an app handler), serves c.Assets as SPA must: every page, shell file name, listed file (with and without gzip, with a Range it ignores, and with an If-Match it holds and one it fails), unlisted file, sourcemap, dot-file, the manifest, /favicon.ico, a same-origin and a cross-site POST, a path under c.APIPrefix and an unknown path. Each answer outside c.APIPrefix carries exactly SPAPolicy(c.CSPAdd) and its status, body, table content type, Cache-Control and ETag; a refusal SPA writes decodes as the envelope with no-store. A missing or unreadable bundle is fatal.

Types

This section is empty.

Jump to

Keyboard shortcuts

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