本文整理汇总了Golang中github.com/ursiform/forest.New函数的典型用法代码示例。如果您正苦于以下问题:Golang New函数的具体用法?Golang New怎么用?Golang New使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了New函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Golang代码示例。
示例1: TestAuthenticateFailure
func TestAuthenticateFailure(t *testing.T) {
method := "GET"
path := root + "/authenticate/failure"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusUnauthorized, success: false}
makeRequest(t, app, params, want)
}
示例2: TestSessionGetSuccessCreateEmpty
func TestSessionGetSuccessCreateEmpty(t *testing.T) {
method := "GET"
path := root + "/session-get"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例3: TestMethodNotAllowed
func TestMethodNotAllowed(t *testing.T) {
method := "OPTIONS"
path := root
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusMethodNotAllowed, success: false}
makeRequest(t, app, params, want)
}
示例4: TestServerError
func TestServerError(t *testing.T) {
method := "GET"
path := root + "/server-error"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusInternalServerError, success: false}
makeRequest(t, app, params, want)
}
示例5: TestNotFound
func TestNotFound(t *testing.T) {
method := "GET"
path := root + "/not-found"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusNotFound, success: false}
makeRequest(t, app, params, want)
}
示例6: TestCSRFFailureBodyNil
func TestCSRFFailureBodyNil(t *testing.T) {
method := "GET"
path := root + "/csrf"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusBadRequest, success: false}
makeRequest(t, app, params, want)
}
示例7: TestAuthenticateSuccess
func TestAuthenticateSuccess(t *testing.T) {
method := "GET"
path := root + "/authenticate/success"
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例8: TestSessionSetUpdateError
func TestSessionSetUpdateError(t *testing.T) {
method := "GET"
path := root + "/session-set"
auth := sessionIDWithUpdateError
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{auth: auth, method: method, path: path}
want := &wanted{code: http.StatusInternalServerError, success: false}
makeRequest(t, app, params, want)
}
示例9: TestSessionSetSuccess
func TestSessionSetSuccess(t *testing.T) {
method := "GET"
path := root + "/session-set"
auth := sessionIDExistent
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{auth: auth, method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例10: TestSessionGetSuccessCreateErrorWithDeleteError
func TestSessionGetSuccessCreateErrorWithDeleteError(t *testing.T) {
method := "GET"
path := root + "/session-get/create-error"
auth := sessionIDWithDeleteError
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{auth: auth, method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例11: TestCSRFSuccess
func TestCSRFSuccess(t *testing.T) {
method := "GET"
path := root + "/csrf"
body := []byte(fmt.Sprintf("{\"sessionid\": \"%s\"}", sessionIDExistent))
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{body: body, method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例12: TestCSRFFailureWrongSessionID
func TestCSRFFailureWrongSessionID(t *testing.T) {
method := "GET"
path := root + "/csrf"
body := []byte(fmt.Sprintf("{\"sessionid\": \"WRONG-SESSION-ID\"}"))
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{body: body, method: method, path: path}
want := &wanted{code: http.StatusBadRequest, success: false}
makeRequest(t, app, params, want)
}
示例13: TestBodyParserSuccess
func TestBodyParserSuccess(t *testing.T) {
method := "POST"
path := root + "/body-parser/success"
body := []byte(arbitraryJSON)
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{body: body, method: method, path: path}
want := &wanted{code: http.StatusOK, success: true}
makeRequest(t, app, params, want)
}
示例14: TestBodyParserFailureNoInit
func TestBodyParserFailureNoInit(t *testing.T) {
method := "POST"
path := root + "/body-parser/failure/no-init"
body := []byte(arbitraryJSON)
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{body: body, method: method, path: path}
want := &wanted{code: http.StatusInternalServerError, success: false}
makeRequest(t, app, params, want)
}
示例15: TestBodyParserFailureBadInput
func TestBodyParserFailureBadInput(t *testing.T) {
method := "POST"
path := root + "/body-parser/success"
body := []byte("{BAD JSON}")
app := forest.New("")
app.RegisterRoute(root, newRouter(app))
params := &requested{body: body, method: method, path: path}
want := &wanted{code: http.StatusBadRequest, success: false}
makeRequest(t, app, params, want)
}