Documentation ¶
Index ¶
- Constants
- func RevelTestHelper(m *testing.M, mode string, runner func(port int))
- type GoContext
- type GoCookie
- type GoHeader
- func (r *GoHeader) Add(key string, value string)
- func (r *GoHeader) Del(key string)
- func (r *GoHeader) Get(key string) (value []string)
- func (r *GoHeader) GetCookie(key string) (value revel.ServerCookie, err error)
- func (r *GoHeader) GetKeys() (value []string)
- func (r *GoHeader) Set(key string, value string)
- func (r *GoHeader) SetCookie(cookie string)
- func (r *GoHeader) SetStatus(statusCode int)
- type GoHttpServer
- func (g *GoHttpServer) Engine() interface{}
- func (g *GoHttpServer) Event(event revel.Event, args interface{}) revel.EventResponse
- func (g *GoHttpServer) Handle(w http.ResponseWriter, r *http.Request)
- func (g *GoHttpServer) Init(init *revel.EngineInit)
- func (g *GoHttpServer) Name() string
- func (g *GoHttpServer) Start()
- func (g *GoHttpServer) Stats() map[string]interface{}
- type GoMultipartForm
- type GoRequest
- func (r *GoRequest) Destroy()
- func (r *GoRequest) Get(key int) (value interface{}, err error)
- func (r *GoRequest) GetForm() (url.Values, error)
- func (r *GoRequest) GetHeader() revel.ServerHeader
- func (r *GoRequest) GetMultipartForm() (revel.ServerMultipartForm, error)
- func (r *GoRequest) GetRaw() interface{}
- func (r *GoRequest) Set(key int, value interface{}) bool
- func (r *GoRequest) SetRequest(req *http.Request)
- type GoResponse
- func (r *GoResponse) Destroy()
- func (r *GoResponse) Get(key int) (value interface{}, err error)
- func (r *GoResponse) GetRaw() interface{}
- func (r *GoResponse) Header() revel.ServerHeader
- func (r *GoResponse) Set(key int, value interface{}) (set bool)
- func (r *GoResponse) SetResponse(w http.ResponseWriter)
- func (r *GoResponse) SetWriter(writer io.Writer)
- func (r *GoResponse) WriteStream(name string, contentlen int64, modtime time.Time, reader io.Reader) error
- type GoWebSocket
- 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) *TestSuite
- 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) *TestSuite
- func (t *TestSuite) PatchCustom(uri string, contentType string, reader io.Reader) *TestRequest
- func (t *TestSuite) Post(path string, contentType string, reader io.Reader) *TestSuite
- func (t *TestSuite) PostCustom(uri string, contentType string, reader io.Reader) *TestRequest
- func (t *TestSuite) PostFile(path string, params url.Values, filePaths url.Values) *TestSuite
- func (t *TestSuite) PostFileCustom(uri string, params url.Values, filePaths url.Values) *TestRequest
- func (t *TestSuite) PostForm(path string, data url.Values) *TestSuite
- 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) *TestSuite
- func (t *TestSuite) PutFormCustom(uri string, data url.Values) *TestRequest
- func (t *TestSuite) WebSocket(path string) *websocket.Conn
- func (t *TestSuite) WebSocketUrl() string
Constants ¶
const GO_NATIVE_TEST_SERVER_ENGINE = "go-test"
Variables ¶
This section is empty.
Functions ¶
Types ¶
type GoContext ¶
type GoContext struct { Request *GoRequest Response *GoResponse WebSocket *GoWebSocket }
func NewGOContext ¶
func NewGOContext(instance *GoHttpServer) *GoContext
func (*GoContext) GetRequest ¶
func (c *GoContext) GetRequest() revel.ServerRequest
func (*GoContext) GetResponse ¶
func (c *GoContext) GetResponse() revel.ServerResponse
type GoHeader ¶
type GoHeader struct { Source interface{} // contains filtered or unexported fields }
func (*GoHeader) GetCookie ¶
func (r *GoHeader) GetCookie(key string) (value revel.ServerCookie, err error)
type GoHttpServer ¶
type GoHttpServer struct { Server *http.Server // Although unused this is here just to support possible code requests ServerInit *revel.EngineInit // The intiialization data MaxMultipartSize int64 TestChannel chan *TestRequest StartedChan chan bool }
func (*GoHttpServer) Engine ¶
func (g *GoHttpServer) Engine() interface{}
func (*GoHttpServer) Event ¶
func (g *GoHttpServer) Event(event revel.Event, args interface{}) revel.EventResponse
func (*GoHttpServer) Handle ¶
func (g *GoHttpServer) Handle(w http.ResponseWriter, r *http.Request)
func (*GoHttpServer) Init ¶
func (g *GoHttpServer) Init(init *revel.EngineInit)
func (*GoHttpServer) Name ¶
func (g *GoHttpServer) Name() string
func (*GoHttpServer) Start ¶
func (g *GoHttpServer) Start()
The server is started and continues to listen on the TestChannel until it is ended.
func (*GoHttpServer) Stats ¶
func (g *GoHttpServer) Stats() map[string]interface{}
type GoMultipartForm ¶
func (*GoMultipartForm) GetFiles ¶
func (f *GoMultipartForm) GetFiles() map[string][]*multipart.FileHeader
func (*GoMultipartForm) GetValues ¶
func (f *GoMultipartForm) GetValues() url.Values
func (*GoMultipartForm) RemoveAll ¶
func (f *GoMultipartForm) RemoveAll() error
type GoRequest ¶
type GoRequest struct { Original *http.Request FormParsed bool MultiFormParsed bool WebSocket *websocket.Conn ParsedForm *GoMultipartForm Goheader *GoHeader Engine *GoHttpServer }
func (*GoRequest) GetHeader ¶
func (r *GoRequest) GetHeader() revel.ServerHeader
func (*GoRequest) GetMultipartForm ¶
func (r *GoRequest) GetMultipartForm() (revel.ServerMultipartForm, error)
func (*GoRequest) SetRequest ¶
type GoResponse ¶
type GoResponse struct { Original http.ResponseWriter Goheader *GoHeader Writer io.Writer Request *GoRequest Engine *GoHttpServer }
func (*GoResponse) Destroy ¶
func (r *GoResponse) Destroy()
func (*GoResponse) Get ¶
func (r *GoResponse) Get(key int) (value interface{}, err error)
func (*GoResponse) GetRaw ¶
func (r *GoResponse) GetRaw() interface{}
func (*GoResponse) Header ¶
func (r *GoResponse) Header() revel.ServerHeader
func (*GoResponse) Set ¶
func (r *GoResponse) Set(key int, value interface{}) (set bool)
func (*GoResponse) SetResponse ¶
func (r *GoResponse) SetResponse(w http.ResponseWriter)
func (*GoResponse) SetWriter ¶
func (r *GoResponse) SetWriter(writer io.Writer)
func (*GoResponse) WriteStream ¶
type GoWebSocket ¶
type GoWebSocket struct { Conn *websocket.Conn GoResponse }
func (*GoWebSocket) MessageReceiveJSON ¶
func (g *GoWebSocket) MessageReceiveJSON(v interface{}) error
func (*GoWebSocket) MessageSendJSON ¶
func (g *GoWebSocket) MessageSendJSON(v interface{}) error
type TestRequest ¶
func (*TestRequest) MakeRequest ¶
func (r *TestRequest) MakeRequest() *TestRequest
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() *TestRequest
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 { Response *httptest.ResponseRecorder // The response recorder ResponseChannel chan bool // The response channel Session session.Session // The session SessionEngine revel.SessionEngine // The session engine Sent bool // True if sent T *testing.T // The test to handle any errors Client *http.Client // The client to extract the cookie data }
TestSuite container.
func NewTestSuite ¶
Start a new request, with a new session.
func NewTestSuiteEngine ¶
func NewTestSuiteEngine(engine revel.SessionEngine, t *testing.T) *TestSuite
Define a new test suite with a custom session engine.
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 possible 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 ¶
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 ¶
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"