Home / Function/ TestRenderYAML() — gin Function Reference

TestRenderYAML() — gin Function Reference

Architecture documentation for the TestRenderYAML() function in render_test.go from the gin codebase.

Entity Profile

Relationship Graph

Source Code

render/render_test.go lines 276–298

func TestRenderYAML(t *testing.T) {
	w := httptest.NewRecorder()
	data := `
a : Easy!
b:
	c: 2
	d: [3, 4]
	`
	(YAML{data}).WriteContentType(w)
	assert.Equal(t, "application/yaml; charset=utf-8", w.Header().Get("Content-Type"))

	err := (YAML{data}).Render(w)
	require.NoError(t, err)

	// With github.com/goccy/go-yaml, the output format is different from gopkg.in/yaml.v3
	// We're checking that the output contains the expected data, not the exact formatting
	output := w.Body.String()
	assert.Contains(t, output, "a : Easy!")
	assert.Contains(t, output, "b:")
	assert.Contains(t, output, "c: 2")
	assert.Contains(t, output, "d: [3, 4]")
	assert.Equal(t, "application/yaml; charset=utf-8", w.Header().Get("Content-Type"))
}

Subdomains

Analyze Your Own Codebase

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

Try Supermodel Free