Documentation ¶
Index ¶
- func GetCookie(w *httptest.ResponseRecorder, name string) (*http.Cookie, error)
- func GetCookies(w *httptest.ResponseRecorder) ([]*http.Cookie, error)
- func StubCreator(basedir string, c *http.Client) *http.Client
- func StubFile(mapping map[string]string, c *http.Client) *http.Client
- func UseStubServer(handler http.Handler, f func(*StubServer))
- type StubServer
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func GetCookies ¶
func GetCookies(w *httptest.ResponseRecorder) ([]*http.Cookie, error)
func StubCreator ¶
StubCreator returns *http.Client that creates files for stubs by real accesses if stub file does not exists. The stub files are created(or used) at {basedir}/{domain}/{path} structure.
func StubFile ¶
StubFile is like a Stub but access local file resources instead of making actual HTTP requests. The following fields are valid and others should not be used in your test.
- .Status
- .StatusCode
- .Header.Get("content-type")
- .ContentLength
- .Body
If you want to test full http request transactions, use StubServer instead.
func UseStubServer ¶
func UseStubServer(handler http.Handler, f func(*StubServer))
UseStubServer launches a stub server configured by handler and execute test function f.
Types ¶
type StubServer ¶
type StubServer struct {
// contains filtered or unexported fields
}
StubServer is an http server that serve the request as stub.
Click to show internal directories.
Click to hide internal directories.