MCPcopy
hub / github.com/gin-gonic/gin / TestContextRenderFile

Function TestContextRenderFile

context_test.go:1417–1429  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1415}
1416
1417func TestContextRenderFile(t *testing.T) {
1418 w := httptest.NewRecorder()
1419 c, _ := CreateTestContext(w)
1420
1421 c.Request, _ = http.NewRequest(http.MethodGet, "/", nil)
1422 c.File("./gin.go")
1423
1424 assert.Equal(t, http.StatusOK, w.Code)
1425 assert.Contains(t, w.Body.String(), "func New(opts ...OptionFunc) *Engine {")
1426 // Content-Type='text/plain; charset=utf-8' when go version <= 1.16,
1427 // else, Content-Type='text/x-go; charset=utf-8'
1428 assert.NotEmpty(t, w.Header().Get("Content-Type"))
1429}
1430
1431func TestContextRenderFileFromFS(t *testing.T) {
1432 w := httptest.NewRecorder()

Callers

nothing calls this directly

Calls 5

CreateTestContextFunction · 0.85
FileMethod · 0.80
StringMethod · 0.65
GetMethod · 0.45
HeaderMethod · 0.45

Tested by

no test coverage detected