Documentation
¶
Overview ¶
Package fixture serves saved tgju.org pages to the test suites.
The pages are real markup, trimmed to a handful of rows per table so the repository stays small, with the giant tooltip attributes stripped. Keeping one copy behind an embed means the parser tests, the client tests and the server tests all agree on what tgju looks like, and that refreshing the fixtures is a single step.
It is an internal package, so importing testing here costs no user of the library anything.
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Paths = map[string]string{
"/currency": "testdata/currency.html",
"/gold-chart": "testdata/gold.html",
"/coin": "testdata/coin.html",
}
Paths maps the tgju.org path of each supported board onto its fixture.
Functions ¶
func Server ¶
Server starts an HTTP server that answers the tgju.org board paths with the saved pages and everything else with 404. It is shut down when the test ends.
client := tgju.New(tgju.WithBaseURL(fixture.Server(t).URL))
func ServerFunc ¶
ServerFunc is Server with a hook that runs before every response. Use it to count requests, to assert on headers, or to fail a request on purpose:
srv := fixture.ServerFunc(t, func(w http.ResponseWriter, r *http.Request) bool {
w.WriteHeader(http.StatusTooManyRequests)
return false // the fixture is not written
})
The hook returns false to take over the response entirely.
Types ¶
This section is empty.