Home / Function/ TestContextRenderDataFromReader() — gin Function Reference

TestContextRenderDataFromReader() — gin Function Reference

Architecture documentation for the TestContextRenderDataFromReader() function in context_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  fe546afe_a481_a8ca_ea2d_8629d9621d5c["TestContextRenderDataFromReader()"]
  ebe0ae48_a62b_a38f_5bac_5bbbd96fc508["context_test.go"]
  fe546afe_a481_a8ca_ea2d_8629d9621d5c -->|defined in| ebe0ae48_a62b_a38f_5bac_5bbbd96fc508
  style fe546afe_a481_a8ca_ea2d_8629d9621d5c fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

context_test.go lines 2950–2967

func TestContextRenderDataFromReader(t *testing.T) {
	w := httptest.NewRecorder()
	c, _ := CreateTestContext(w)

	body := "#!PNG some raw data"
	reader := strings.NewReader(body)
	contentLength := int64(len(body))
	contentType := "image/png"
	extraHeaders := map[string]string{"Content-Disposition": `attachment; filename="gopher.png"`}

	c.DataFromReader(http.StatusOK, contentLength, contentType, reader, extraHeaders)

	assert.Equal(t, http.StatusOK, w.Code)
	assert.Equal(t, body, w.Body.String())
	assert.Equal(t, contentType, w.Header().Get("Content-Type"))
	assert.Equal(t, strconv.FormatInt(contentLength, 10), w.Header().Get("Content-Length"))
	assert.Equal(t, extraHeaders["Content-Disposition"], w.Header().Get("Content-Disposition"))
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestContextRenderDataFromReader() do?
TestContextRenderDataFromReader() is a function in the gin codebase, defined in context_test.go.
Where is TestContextRenderDataFromReader() defined?
TestContextRenderDataFromReader() is defined in context_test.go at line 2950.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free