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

Function TestRaceContextCopy

githubapi_test.go:351–365  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

349}
350
351func TestRaceContextCopy(t *testing.T) {
352 DefaultWriter = os.Stdout
353 router := Default()
354 router.GET("/test/copy/race", func(c *Context) {
355 c.Set("1", 0)
356 c.Set("2", 0)
357
358 // Sending a copy of the Context to two separate routines
359 go readWriteKeys(c.Copy())
360 go readWriteKeys(c.Copy())
361 c.String(http.StatusOK, "run OK, no panics")
362 })
363 w := PerformRequest(router, http.MethodGet, "/test/copy/race")
364 assert.Equal(t, "run OK, no panics", w.Body.String())
365}
366
367func readWriteKeys(c *Context) {
368 for {

Callers

nothing calls this directly

Calls 7

readWriteKeysFunction · 0.85
PerformRequestFunction · 0.85
SetMethod · 0.80
CopyMethod · 0.80
DefaultFunction · 0.70
GETMethod · 0.65
StringMethod · 0.65

Tested by

no test coverage detected