revel: github.com/revel/revel/testing Index | Files

package testing

import "github.com/revel/revel/testing"

Index

Package Files

testsuite.go

Variables

var TestSuites []interface{} // Array of structs that embed TestSuite

type TestRequest Uses

type TestRequest struct {
    *http.Request
    // contains filtered or unexported fields
}

func (*TestRequest) MakeRequest Uses

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 Uses

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 Uses

type TestSuite struct {
    Client       *http.Client
    Response     *http.Response
    ResponseBody []byte
    Session      revel.Session
}

func NewTestSuite Uses

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) Assert Uses

func (t *TestSuite) Assert(exp bool)

func (*TestSuite) AssertContains Uses

func (t *TestSuite) AssertContains(s string)

AssertContains asserts that the response contains the given string.

func (*TestSuite) AssertContainsRegex Uses

func (t *TestSuite) AssertContainsRegex(regex string)

AssertContainsRegex asserts that the response matches the given regular expression.

func (*TestSuite) AssertContentType Uses

func (t *TestSuite) AssertContentType(contentType string)

func (*TestSuite) AssertEqual Uses

func (t *TestSuite) AssertEqual(expected, actual interface{})

func (*TestSuite) AssertHeader Uses

func (t *TestSuite) AssertHeader(name, value string)

func (*TestSuite) AssertNotContains Uses

func (t *TestSuite) AssertNotContains(s string)

AssertNotContains asserts that the response does not contain the given string.

func (*TestSuite) AssertNotEqual Uses

func (t *TestSuite) AssertNotEqual(expected, actual interface{})

func (*TestSuite) AssertNotFound Uses

func (t *TestSuite) AssertNotFound()

func (*TestSuite) AssertOk Uses

func (t *TestSuite) AssertOk()

func (*TestSuite) AssertStatus Uses

func (t *TestSuite) AssertStatus(status int)

func (*TestSuite) Assertf Uses

func (t *TestSuite) Assertf(exp bool, formatStr string, args ...interface{})

func (*TestSuite) BaseUrl Uses

func (t *TestSuite) BaseUrl() string

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 Uses

func (t *TestSuite) Delete(path string)

Delete issues a DELETE request to the given path and stores the result in Response and ResponseBody.

func (*TestSuite) DeleteCustom Uses

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 Uses

func (t *TestSuite) Get(path string)

Get issues a GET request to the given path and stores the result in Response and ResponseBody.

func (*TestSuite) GetCustom Uses

func (t *TestSuite) GetCustom(uri string) *TestRequest

GetCustom returns a GET request to the given URI in a form of its wrapper.

func (*TestSuite) Host Uses

func (t *TestSuite) Host() string

Host returns the address and port of the server, e.g. "127.0.0.1:8557"

func (*TestSuite) NewTestRequest Uses

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 Uses

func (t *TestSuite) Patch(path string, contentType string, reader io.Reader)

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 Uses

func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader) *TestRequest

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 Uses

func (t *TestSuite) Post(path string, contentType string, reader io.Reader)

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 Uses

func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader) *TestRequest

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 Uses

func (t *TestSuite) PostFile(path string, params url.Values, filePaths url.Values)

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 Uses

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 Uses

func (t *TestSuite) PostForm(path string, data url.Values)

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 Uses

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 Uses

func (t *TestSuite) Put(path string, contentType string, reader io.Reader)

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 Uses

func (t *TestSuite) PutCustom(uri string, contentType string, reader io.Reader) *TestRequest

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 Uses

func (t *TestSuite) PutForm(path string, data url.Values)

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 Uses

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 Uses

func (t *TestSuite) WebSocket(path string) *websocket.Conn

WebSocket creates a websocket connection to the given path and returns it

func (*TestSuite) WebSocketUrl Uses

func (t *TestSuite) WebSocketUrl() string

WebSocketUrl returns the base websocket URL of the server, e.g. "ws://127.0.0.1:8557"

Package testing imports 16 packages (graph) and is imported by 28 packages. Updated 2017-03-25. Refresh now. Tools for package owners.