Home / Function/ TestPanicClean() — gin Function Reference

TestPanicClean() — gin Function Reference

Architecture documentation for the TestPanicClean() function in recovery_test.go from the gin codebase.

Entity Profile

Dependency Diagram

graph TD
  d263c2e1_933f_5cdb_c860_2fb1a5082a83["TestPanicClean()"]
  c9a553a7_05a4_91a7_23b0_924f9f59d021["recovery_test.go"]
  d263c2e1_933f_5cdb_c860_2fb1a5082a83 -->|defined in| c9a553a7_05a4_91a7_23b0_924f9f59d021
  style d263c2e1_933f_5cdb_c860_2fb1a5082a83 fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

recovery_test.go lines 18–47

func TestPanicClean(t *testing.T) {
	buffer := new(strings.Builder)
	router := New()
	password := "my-super-secret-password"
	router.Use(RecoveryWithWriter(buffer))
	router.GET("/recovery", func(c *Context) {
		c.AbortWithStatus(http.StatusBadRequest)
		panic("Oupps, Houston, we have a problem")
	})
	// RUN
	w := PerformRequest(router, http.MethodGet, "/recovery",
		header{
			Key:   "Host",
			Value: "www.google.com",
		},
		header{
			Key:   "Authorization",
			Value: "Bearer " + password,
		},
		header{
			Key:   "Content-Type",
			Value: "application/json",
		},
	)
	// TEST
	assert.Equal(t, http.StatusBadRequest, w.Code)

	// Check the buffer does not have the secret key
	assert.NotContains(t, buffer.String(), password)
}

Domain

Subdomains

Defined In

Frequently Asked Questions

What does TestPanicClean() do?
TestPanicClean() is a function in the gin codebase, defined in recovery_test.go.
Where is TestPanicClean() defined?
TestPanicClean() is defined in recovery_test.go at line 18.

Analyze Your Own Codebase

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

Try Supermodel Free