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 the package's struct or of ErrorResponse; another package's functions do not write.
func CheckNoUI ¶
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 ¶
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.