TestContextRenderHTML2() — gin Function Reference
Architecture documentation for the TestContextRenderHTML2() function in context_test.go from the gin codebase.
Entity Profile
Dependency Diagram
graph TD 47ff5d49_c5d8_5fdc_17ba_c9082921b349["TestContextRenderHTML2()"] ebe0ae48_a62b_a38f_5bac_5bbbd96fc508["context_test.go"] 47ff5d49_c5d8_5fdc_17ba_c9082921b349 -->|defined in| ebe0ae48_a62b_a38f_5bac_5bbbd96fc508 style 47ff5d49_c5d8_5fdc_17ba_c9082921b349 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
context_test.go lines 1259–1281
func TestContextRenderHTML2(t *testing.T) {
w := httptest.NewRecorder()
c, router := CreateTestContext(w)
// print debug warning log when Engine.trees > 0
router.addRoute(http.MethodGet, "/", HandlersChain{func(_ *Context) {}})
assert.Len(t, router.trees, 1)
templ := template.Must(template.New("t").Parse(`Hello {{.name}}`))
re := captureOutput(t, func() {
SetMode(DebugMode)
router.SetHTMLTemplate(templ)
SetMode(TestMode)
})
assert.Equal(t, "[GIN-debug] [WARNING] Since SetHTMLTemplate() is NOT thread-safe. It should only be called\nat initialization. ie. before any route is registered or the router is listening in a socket:\n\n\trouter := gin.Default()\n\trouter.SetHTMLTemplate(template) // << good place\n\n", re)
c.HTML(http.StatusCreated, "t", H{"name": "alexandernyquist"})
assert.Equal(t, http.StatusCreated, w.Code)
assert.Equal(t, "Hello alexandernyquist", w.Body.String())
assert.Equal(t, "text/html; charset=utf-8", w.Header().Get("Content-Type"))
}
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does TestContextRenderHTML2() do?
TestContextRenderHTML2() is a function in the gin codebase, defined in context_test.go.
Where is TestContextRenderHTML2() defined?
TestContextRenderHTML2() is defined in context_test.go at line 1259.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free