Home / Function/ TestContextFileSimple() — gin Function Reference

TestContextFileSimple() — gin Function Reference

Architecture documentation for the TestContextFileSimple() function in context_file_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

context_file_test.go lines 12–24

func TestContextFileSimple(t *testing.T) {
	// Test serving an existing file
	testFile := "testdata/test_file.txt"
	w := httptest.NewRecorder()
	c, _ := CreateTestContext(w)
	c.Request = httptest.NewRequest(http.MethodGet, "/test", nil)

	c.File(testFile)

	assert.Equal(t, http.StatusOK, w.Code)
	assert.Contains(t, w.Body.String(), "This is a test file")
	assert.Equal(t, "text/plain; charset=utf-8", w.Header().Get("Content-Type"))
}

Domain

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free