Skip to content
Myr

docs(test): improved GoDoc in test_helpers.go (#4270)

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by 諏訪原慶斗 · committed by GitHub · parent 32065bb · Browse files · 1 file+9 added−2 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

1 file+9 added−2 removed

  • other:+9 added−2 removed

1 file+9 added−2 removed

modified:test_helpers.go+9 added-2 removed
4 unmodified lines
5package gin67import "net/http"89// CreateTestContext returns a fresh engine and context for testing purposes9// CreateTestContext returns a fresh Engine and a Context associated with it.10// This is useful for tests that need to set up a new Gin engine instance11// along with a context, for example, to test middleware that doesn't depend on12// specific routes. The ResponseWriter `w` is used to initialize the context's writer.13func CreateTestContext(w http.ResponseWriter) (c *Context, r *Engine) {14 r = New()15 c = r.allocateContext(0)16 c.reset()17 c.writermem.reset(w)18 return19}2018// CreateTestContextOnly returns a fresh context base on the engine for testing purposes21// CreateTestContextOnly returns a fresh Context associated with the provided Engine `r`.22// This is useful for tests that operate on an existing, possibly pre-configured,23// Gin engine instance and need a new context for it.24// The ResponseWriter `w` is used to initialize the context's writer.25// The context is allocated with the `maxParams` setting from the provided engine.26func CreateTestContextOnly(w http.ResponseWriter, r *Engine) (c *Context) {27 c = r.allocateContext(r.maxParams)28 c.reset()29 c.writermem.reset(w)
2 unmodified lines