MCPcopy
hub / github.com/gin-gonic/gin / CreateTestContextOnly

Function CreateTestContextOnly

test_helpers.go:30–35  ·  view source on GitHub ↗

CreateTestContextOnly returns a fresh Context associated with the provided Engine `r`. This is useful for tests that operate on an existing, possibly pre-configured, Gin engine instance and need a new context for it. The ResponseWriter `w` is used to initialize the context's writer. The context is a

(w http.ResponseWriter, r *Engine)

Source from the content-addressed store, hash-verified

28// The ResponseWriter `w` is used to initialize the context's writer.
29// The context is allocated with the `maxParams` setting from the provided engine.
30func CreateTestContextOnly(w http.ResponseWriter, r *Engine) (c *Context) {
31 c = r.allocateContext(r.maxParams)
32 c.reset()
33 c.writermem.reset(w)
34 return
35}
36
37// waitForServerReady waits for a server to be ready by making HTTP requests
38// with exponential backoff. This is more reliable than time.Sleep() for testing.

Callers 1

Calls 2

allocateContextMethod · 0.80
resetMethod · 0.45

Tested by 1