Documentation
¶
Overview ¶
Package foliotest drives a folio app (or any http.Handler) in tests, keeping cookies between requests like a browser.
func TestHome(t *testing.T) {
c := foliotest.New(t, app.Handler())
c.Get("/").ExpectStatus(200).ExpectContains("Welcome")
c.PostForm("/", url.Values{"name": {"Ada"}}).ExpectRedirect("/").Follow().ExpectContains("Saved")
}
Index ¶
Constants ¶
View Source
const BaseURL = "http://example.com"
BaseURL is the origin requests are made against.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// Header is added to every request.
Header http.Header
// contains filtered or unexported fields
}
Client sends requests straight to a handler, without a network.
func (*Client) Do ¶
Do sends req with the client's cookies and headers. Redirects aren't followed; see Response.Follow.
type Response ¶
type Response struct {
Code int
Header http.Header
Body string
// contains filtered or unexported fields
}
Response is a recorded response with chainable assertions.
func (*Response) ExpectContains ¶
ExpectContains fails the test unless the body contains s.
func (*Response) ExpectNotContains ¶
ExpectNotContains fails the test if the body contains s.
func (*Response) ExpectRedirect ¶
ExpectRedirect fails the test unless the response redirects to location.
func (*Response) ExpectStatus ¶
ExpectStatus fails the test unless the status is code.
Click to show internal directories.
Click to hide internal directories.