Home / Function/ TestContextBadAutoBind() — gin Function Reference

TestContextBadAutoBind() — gin Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

context_test.go lines 2287–2306

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

	c.Request, _ = http.NewRequest(http.MethodPost, "http://example.com", strings.NewReader("\"foo\":\"bar\", \"bar\":\"foo\"}"))
	c.Request.Header.Add("Content-Type", MIMEJSON)
	var obj struct {
		Foo string `json:"foo"`
		Bar string `json:"bar"`
	}

	assert.False(t, c.IsAborted())
	require.Error(t, c.Bind(&obj))
	c.Writer.WriteHeaderNow()

	assert.Empty(t, obj.Bar)
	assert.Empty(t, obj.Foo)
	assert.Equal(t, http.StatusBadRequest, w.Code)
	assert.True(t, c.IsAborted())
}

Domain

Subdomains

Defined In

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free