Home / Function/ TestContextError() — gin Function Reference

TestContextError() — gin Function Reference

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

Entity Profile

Dependency Diagram

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

Relationship Graph

Source Code

context_test.go lines 1886–1919

func TestContextError(t *testing.T) {
	c, _ := CreateTestContext(httptest.NewRecorder())
	assert.Empty(t, c.Errors)

	firstErr := errors.New("first error")
	c.Error(firstErr) //nolint: errcheck
	assert.Len(t, c.Errors, 1)
	assert.Equal(t, "Error #01: first error\n", c.Errors.String())

	secondErr := errors.New("second error")
	c.Error(&Error{ //nolint: errcheck
		Err:  secondErr,
		Meta: "some data 2",
		Type: ErrorTypePublic,
	})
	assert.Len(t, c.Errors, 2)

	assert.Equal(t, firstErr, c.Errors[0].Err)
	assert.Nil(t, c.Errors[0].Meta)
	assert.Equal(t, ErrorTypePrivate, c.Errors[0].Type)

	assert.Equal(t, secondErr, c.Errors[1].Err)
	assert.Equal(t, "some data 2", c.Errors[1].Meta)
	assert.Equal(t, ErrorTypePublic, c.Errors[1].Type)

	assert.Equal(t, c.Errors.Last(), c.Errors[1])

	defer func() {
		if recover() == nil {
			t.Error("didn't panic")
		}
	}()
	c.Error(nil) //nolint: errcheck
}

Domain

Subdomains

Defined In

Frequently Asked Questions

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

Analyze Your Own Codebase

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

Try Supermodel Free