FazBrowse GitHub Viewer
|
Trending
|
URL:
|
Home
Tools:
[Download Repo ZIP]
[View Raw Code]
[Original HTTPS Page]
echo/renderer_test.go at master · labstack/echo · GitHub
Uh oh!
There was an error while loading.
Please reload this page
.
labstack
/
echo
Public
Uh oh!
There was an error while loading.
Please reload this page
.
Notifications
You must be signed in to change notification settings
Fork
2.4k
Star
32.7k
Code
Issues
8
Pull requests
20
Discussions
Actions
Projects
Wiki
Security and quality
2
Insights
Additional navigation options
Code
Issues
Pull requests
Discussions
Actions
Projects
Wiki
Security and quality
Insights
Expand file tree
Breadcrumbs
echo
/
renderer_test.go
Copy path
More file actions
More file actions
Latest commit
History
History
History
28 lines (25 loc) · 738 Bytes
Breadcrumbs
echo
/
renderer_test.go
Copy path
File metadata and controls
28 lines (25 loc) · 738 Bytes
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// SPDX-License-Identifier: MIT
// SPDX-FileCopyrightText: © 2015 LabStack LLC and Echo contributors
package
echo
import
(
"github.com/stretchr/testify/assert"
"html/template"
"net/http"
"net/http/httptest"
"strings"
"testing"
)
func
TestRenderWithTemplateRenderer
(
t
*
testing.
T
) {
e
:=
New
()
req
:=
httptest
.
NewRequest
(
http
.
MethodPost
,
"/"
,
strings
.
NewReader
(
userJSON
))
rec
:=
httptest
.
NewRecorder
()
c
:=
e
.
NewContext
(
req
,
rec
)
e
.
Renderer
=
&
TemplateRenderer
{
Template
:
template
.
Must
(
template
.
New
(
"hello"
).
Parse
(
"Hello, {{.}}!"
)),
}
err
:=
c
.
Render
(
http
.
StatusOK
,
"hello"
,
"Jon Snow"
)
if
assert
.
NoError
(
t
,
err
) {
assert
.
Equal
(
t
,
http
.
StatusOK
,
rec
.
Code
)
assert
.
Equal
(
t
,
"Hello, Jon Snow!"
,
rec
.
Body
.
String
())
}
}
Back
|
FazBrowse Home
|
New Git URL