Documentation ¶
Index ¶
- Variables
- type TestRequest
- type TestSuite
- func (t *TestSuite) Assert(exp bool)
- func (t *TestSuite) AssertContains(s string)
- func (t *TestSuite) AssertContainsRegex(regex string)
- func (t *TestSuite) AssertContentType(contentType string)
- func (t *TestSuite) AssertEqual(expected, actual interface{})
- func (t *TestSuite) AssertHeader(name, value string)
- func (t *TestSuite) AssertNotContains(s string)
- func (t *TestSuite) AssertNotEqual(expected, actual interface{})
- func (t *TestSuite) AssertNotFound()
- func (t *TestSuite) AssertOk()
- func (t *TestSuite) AssertStatus(status int)
- func (t *TestSuite) Assertf(exp bool, formatStr string, args ...interface{})
- func (t *TestSuite) BaseUrl() string
- func (t *TestSuite) Delete(path string)
- func (t *TestSuite) DeleteCustom(uri string) *TestRequest
- func (t *TestSuite) Get(path string)
- func (t *TestSuite) GetCustom(uri string) *TestRequest
- func (t *TestSuite) Host() string
- func (t *TestSuite) NewTestRequest(req *http.Request) *TestRequest
- func (t *TestSuite) Patch(path string, contentType string, reader io.Reader)
- func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader) *TestRequest
- func (t *TestSuite) Post(path string, contentType string, reader io.Reader)
- func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader) *TestRequest
- func (t *TestSuite) PostFile(path string, params url.Values, filePaths url.Values)
- func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.Values) *TestRequest
- func (t *TestSuite) PostForm(path string, data url.Values)
- func (t *TestSuite) PostFormCustom(uri string, data url.Values) *TestRequest
- func (t *TestSuite) Put(path string, contentType string, reader io.Reader)
- func (t *TestSuite) PutCustom(uri string, contentType string, reader io.Reader) *TestRequest
- func (t *TestSuite) PutForm(path string, data url.Values)
- func (t *TestSuite) PutFormCustom(uri string, data url.Values) *TestRequest
- func (t *TestSuite) WebSocket(path string) *websocket.Conn
- func (t *TestSuite) WebSocketUrl() string
Constants ¶
This section is empty.
Variables ¶
var TestSuites []interface{} // Array of structs that embed TestSuite
Functions ¶
This section is empty.
Types ¶
type TestRequest ¶
func (*TestRequest) MakeRequest ¶
func (r *TestRequest) MakeRequest()
Issue any request and read the response. If successful, the caller may examine the Response and ResponseBody properties. You will need to manage session / cookie data manually
func (*TestRequest) Send ¶
func (r *TestRequest) Send()
Issue any request and read the response. If successful, the caller may examine the Response and ResponseBody properties. Session data will be added to the request cookies for you.
type TestSuite ¶
type TestSuite struct { Client *http.Client Response *http.Response ResponseBody []byte Session revel.Session }
func NewTestSuite ¶
func NewTestSuite() TestSuite
NewTestSuite returns an initialized TestSuite ready for use. It is invoked by the test harness to initialize the embedded field in application tests.
func (*TestSuite) AssertContains ¶
Assert that the response contains the given string.
func (*TestSuite) AssertContainsRegex ¶
Assert that the response matches the given regular expression.
func (*TestSuite) AssertContentType ¶
func (*TestSuite) AssertEqual ¶
func (t *TestSuite) AssertEqual(expected, actual interface{})
func (*TestSuite) AssertHeader ¶
func (*TestSuite) AssertNotContains ¶
Assert that the response does not contain the given string.
func (*TestSuite) AssertNotEqual ¶
func (t *TestSuite) AssertNotEqual(expected, actual interface{})
func (*TestSuite) AssertNotFound ¶
func (t *TestSuite) AssertNotFound()
func (*TestSuite) AssertStatus ¶
func (*TestSuite) BaseUrl ¶
Return the base http/https URL of the server, e.g. "http://127.0.0.1:8557". The scheme is set to https if http.ssl is set to true in the configuration file.
func (*TestSuite) Delete ¶
Issue a DELETE request to the given path and store the result in Response and ResponseBody.
func (*TestSuite) DeleteCustom ¶
func (t *TestSuite) DeleteCustom(uri string) *TestRequest
Return a DELETE request to the given uri in a form of its wrapper.
func (*TestSuite) Get ¶
Issue a GET request to the given path and store the result in Response and ResponseBody.
func (*TestSuite) GetCustom ¶
func (t *TestSuite) GetCustom(uri string) *TestRequest
Return a GET request to the given uri in a form of its wrapper.
func (*TestSuite) NewTestRequest ¶
func (t *TestSuite) NewTestRequest(req *http.Request) *TestRequest
NewTestRequest returns an initialized *TestRequest. It is used for extending testsuite package making it possibe to define own methods. Example:
type MyTestSuite struct { testing.TestSuite } func (t *MyTestSuite) PutFormCustom(...) { req := http.NewRequest(...) ... return t.NewTestRequest(req) }
func (*TestSuite) Patch ¶
Issue a PATCH request to the given path, sending the given Content-Type and data, and store the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PatchCustom ¶
Return a PATCH request to the given uri with specified Content-Type and data in a form of wrapper. "data" may be nil.
func (*TestSuite) Post ¶
Issue a POST request to the given path, sending the given Content-Type and data, and store the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PostCustom ¶
Return a POST request to the given uri with specified Content-Type and data in a form of wrapper. "data" may be nil.
func (*TestSuite) PostFile ¶
Issue a multipart request to the given path sending given params and files, and store the result in Response and ResponseBody.
func (*TestSuite) PostFileCustom ¶
func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.Values) *TestRequest
Return a multipart request to the given uri in a form of its wrapper with the given params and files.
func (*TestSuite) PostForm ¶
Issue a POST request to the given path as a form post of the given key and values, and store the result in Response and ResponseBody.
func (*TestSuite) PostFormCustom ¶
func (t *TestSuite) PostFormCustom(uri string, data url.Values) *TestRequest
Return a POST request to the given uri as a form post of the given key and values. The request is in a form of TestRequest wrapper.
func (*TestSuite) Put ¶
Issue a PUT request to the given path, sending the given Content-Type and data, and store the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PutCustom ¶
Return a PUT request to the given uri with specified Content-Type and data in a form of wrapper. "data" may be nil.
func (*TestSuite) PutForm ¶ added in v0.13.0
Issue a PUT request to the given path as a form put of the given key and values, and store the result in Response and ResponseBody.
func (*TestSuite) PutFormCustom ¶ added in v0.13.0
func (t *TestSuite) PutFormCustom(uri string, data url.Values) *TestRequest
Return a PUT request to the given uri as a form put of the given key and values. The request is in a form of TestRequest wrapper.
func (*TestSuite) WebSocket ¶
Create a websocket connection to the given path and return the connection
func (*TestSuite) WebSocketUrl ¶
Return the base websocket URL of the server, e.g. "ws://127.0.0.1:8557"