testing

package
v0.12.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Mar 25, 2015 License: MIT Imports: 16 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

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

Functions

This section is empty.

Types

type TestRequest

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

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

func (t *TestSuite) Assert(exp bool)

func (*TestSuite) AssertContains

func (t *TestSuite) AssertContains(s string)

Assert that the response contains the given string.

func (*TestSuite) AssertContainsRegex

func (t *TestSuite) AssertContainsRegex(regex string)

Assert that the response matches the given regular expression.

func (*TestSuite) AssertContentType

func (t *TestSuite) AssertContentType(contentType string)

func (*TestSuite) AssertEqual

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

func (*TestSuite) AssertHeader

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

func (*TestSuite) AssertNotContains

func (t *TestSuite) AssertNotContains(s string)

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) AssertOk

func (t *TestSuite) AssertOk()

func (*TestSuite) AssertStatus

func (t *TestSuite) AssertStatus(status int)

func (*TestSuite) Assertf

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

func (*TestSuite) BaseUrl

func (t *TestSuite) BaseUrl() string

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

func (t *TestSuite) Delete(path string)

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

func (t *TestSuite) Get(path string)

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) Host

func (t *TestSuite) Host() string

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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) WebSocket

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

Create a websocket connection to the given path and return the connection

func (*TestSuite) WebSocketUrl

func (t *TestSuite) WebSocketUrl() string

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

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL