本文整理匯總了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)
}