Documentation
¶
Overview ¶
Package statictest exports an app inside a test and asserts on the result: files, headers and redirects as the host's preview serves them, and diagnostics.
Index ¶
- type Result
- func (r *Result) Diagnostics(code string) []static.Diagnostic
- func (r *Result) File(path string) string
- func (r *Result) Get(path string) *http.Response
- func (r *Result) HasDiagnostic(code, path string) bool
- func (r *Result) HasFile(path string) bool
- func (r *Result) Header(path, name string) string
- func (r *Result) OK() *Result
- func (r *Result) Redirect(path string) (location string, status int, ok bool)
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Result ¶
type Result struct {
// Dir is the output directory, inside t.TempDir().
Dir string
// Report is the export's report.
Report *static.Report
// Err is the export error: nil, or one wrapping static.ErrExport when
// error diagnostics were found (nothing is written then).
Err error
// contains filtered or unexported fields
}
Result is one export made by Export.
func Export ¶
Export exports app with opts into a temporary directory. A configuration error fails the test at once; error diagnostics are left in Err and Report for the test to assert on.
func ExportWith ¶
func ExportWith(t testing.TB, app static.App, o static.ExportOptions, opts ...static.Option) *Result
ExportWith is Export with explicit ExportOptions. An empty Out becomes a directory inside t.TempDir().
func (*Result) Diagnostics ¶
func (r *Result) Diagnostics(code string) []static.Diagnostic
Diagnostics returns the diagnostics with code, or all of them for "".
func (*Result) File ¶
File returns the contents of an output file, failing the test if it is missing.
func (*Result) Get ¶
Get requests path from the target's preview of the export, so redirects, headers, clean URLs and the 404 page behave as on the host.
func (*Result) HasDiagnostic ¶
HasDiagnostic reports whether a diagnostic with code was found on path ("" for any path).