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

Function TestContextCopy

context_test.go:668–689  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

666}
667
668func TestContextCopy(t *testing.T) {
669 c, _ := CreateTestContext(httptest.NewRecorder())
670 c.index = 2
671 c.Request, _ = http.NewRequest(http.MethodPost, "/hola", nil)
672 c.handlers = HandlersChain{func(c *Context) {}}
673 c.Params = Params{Param{Key: "foo", Value: "bar"}}
674 c.Set("foo", "bar")
675 c.fullPath = "/hola"
676
677 cp := c.Copy()
678 assert.Nil(t, cp.handlers)
679 assert.Nil(t, cp.writermem.ResponseWriter)
680 assert.Equal(t, &cp.writermem, cp.Writer.(*responseWriter))
681 assert.Equal(t, cp.Request, c.Request)
682 assert.Equal(t, abortIndex, cp.index)
683 assert.Equal(t, cp.Keys, c.Keys)
684 assert.Equal(t, cp.engine, c.engine)
685 assert.Equal(t, cp.Params, c.Params)
686 cp.Set("foo", "notBar")
687 assert.NotEqual(t, cp.Keys["foo"], c.Keys["foo"])
688 assert.Equal(t, cp.fullPath, c.fullPath)
689}
690
691func TestContextHandlerName(t *testing.T) {
692 c, _ := CreateTestContext(httptest.NewRecorder())

Callers

nothing calls this directly

Calls 3

CreateTestContextFunction · 0.85
SetMethod · 0.80
CopyMethod · 0.80

Tested by

no test coverage detected