diff --git a/context_test.go b/context_test.go index b82e04d5..a2115bae 100644 --- a/context_test.go +++ b/context_test.go @@ -800,6 +800,29 @@ func TestContextCopyNilErrorsAndAccepted(t *testing.T) { assert.Nil(t, cp.Accepted) } +func TestContextCopyRace(t *testing.T) { + c := &Context{} + + var wg sync.WaitGroup + wg.Add(2) + + go func() { + defer wg.Done() + for range 1000 { + c.Set("foo", "bar") + } + }() + + go func() { + defer wg.Done() + for range 1000 { + c.Copy() + } + }() + + wg.Wait() +} + func TestContextHandlerName(t *testing.T) { c, _ := CreateTestContext(httptest.NewRecorder()) c.handlers = HandlersChain{func(c *Context) {}, handlerNameTest}