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
This is populated by the generated code in the run/run/go file
Functions ¶
This section is empty.
Types ¶
type TestRequest ¶
func (*TestRequest) MakeRequest ¶
func (r *TestRequest) MakeRequest()
MakeRequest issues 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()
Send issues any request and reads 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 ¶
AssertContains asserts that the response contains the given string.
func (*TestSuite) AssertContainsRegex ¶
AssertContainsRegex asserts 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 ¶
AssertNotContains asserts 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 ¶
BaseUrl returns 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 ¶
Delete issues a DELETE request to the given path and stores the result in Response and ResponseBody.
func (*TestSuite) DeleteCustom ¶
func (t *TestSuite) DeleteCustom(uri string) *TestRequest
DeleteCustom returns a DELETE request to the given URI in a form of its wrapper.
func (*TestSuite) Get ¶
Get issues a GET request to the given path and stores the result in Response and ResponseBody.
func (*TestSuite) GetCustom ¶
func (t *TestSuite) GetCustom(uri string) *TestRequest
GetCustom returns 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 ¶
Patch issues a PATCH request to the given path, sending the given Content-Type and data, and stores the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PatchCustom ¶
PatchCustom returns 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 ¶
Post issues a POST request to the given path, sending the given Content-Type and data, storing the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PostCustom ¶
PostCustom returns 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 ¶
PostFile issues a multipart request to the given path sending given params and files, and stores the result in Response and ResponseBody.
func (*TestSuite) PostFileCustom ¶
func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.Values) *TestRequest
PostFileCustom returns a multipart request to the given URI in a form of its wrapper with the given params and files.
func (*TestSuite) PostForm ¶
PostForm issues a POST request to the given path as a form post of the given key and values, and stores the result in Response and ResponseBody.
func (*TestSuite) PostFormCustom ¶
func (t *TestSuite) PostFormCustom(uri string, data url.Values) *TestRequest
PostFormCustom returns 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 ¶
Put issues a PUT request to the given path, sending the given Content-Type and data, storing the result in Response and ResponseBody. "data" may be nil.
func (*TestSuite) PutCustom ¶
PutCustom returns 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
PutForm issues a PUT request to the given path as a form put of the given key and values, and stores the result in Response and ResponseBody.
func (*TestSuite) PutFormCustom ¶ added in v0.13.0
func (t *TestSuite) PutFormCustom(uri string, data url.Values) *TestRequest
PutFormCustom returns 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 ¶
WebSocket creates a websocket connection to the given path and returns it
func (*TestSuite) WebSocketUrl ¶
WebSocketUrl returns the base websocket URL of the server, e.g. "ws://127.0.0.1:8557"