(t *testing.T)
| 349 | } |
| 350 | |
| 351 | func 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 | |
| 367 | func readWriteKeys(c *Context) { |
| 368 | for { |
nothing calls this directly
no test coverage detected