Tests

Variables

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

type TestSuite

type TestSuite struct {
    Client       *http.Client
    Response     *http.Response
    ResponseBody []byte
    Session      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.BUG

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) 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 Request and RequestBody.

func (*TestSuite) Get

func (t *TestSuite) Get(path string)

Issue a GET request to the given path and store the result in Request and RequestBody.

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

func (t *TestSuite) MakeRequest(req *http.Request)

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 (*TestSuite) MakeRequestSession

func (t *TestSuite) MakeRequestSession(req *http.Request)

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.

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 Request and RequestBody. "data" may be nil.

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 Request and RequestBody.

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"