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 non-test Go files in dir write, naming each code missing from specs and each key nothing writes. A code is written when a string literal, a string constant or an ErrorCode conversion of one sits at an ErrorCode argument of a call (to httpserver.WriteError, an ErrorResponder, or a function or func type dir declares) or fills an ErrorCode field of a composite literal. A code held in a variable is not followed; it is counted where its literal enters.
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), 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 decodes as the envelope. A missing or unreadable bundle is fatal.
Types ¶
This section is empty.