當前位置: 首頁>>代碼示例>>Golang>>正文


Golang forest.New函數代碼示例

本文整理匯總了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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:9,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go

示例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)
}
開發者ID:ursiform,項目名稱:forest-wares,代碼行數:10,代碼來源:wares-test_test.go


注:本文中的github.com/ursiform/forest.New函數示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。