(t *testing.T)
| 706 | } |
| 707 | |
| 708 | func TestEngineHandleContextPreventsMiddlewareReEntry(t *testing.T) { |
| 709 | // given |
| 710 | var handlerCounterV1, handlerCounterV2, middlewareCounterV1 int64 |
| 711 | |
| 712 | r := New() |
| 713 | v1 := r.Group("/v1") |
| 714 | { |
| 715 | v1.Use(func(c *Context) { |
| 716 | atomic.AddInt64(&middlewareCounterV1, 1) |
| 717 | }) |
| 718 | v1.GET("/test", func(c *Context) { |
| 719 | atomic.AddInt64(&handlerCounterV1, 1) |
| 720 | c.Status(http.StatusOK) |
| 721 | }) |
| 722 | } |
| 723 | |
| 724 | v2 := r.Group("/v2") |
| 725 | { |
| 726 | v2.GET("/test", func(c *Context) { |
| 727 | c.Request.URL.Path = "/v1/test" |
| 728 | r.HandleContext(c) |
| 729 | }, func(c *Context) { |
| 730 | atomic.AddInt64(&handlerCounterV2, 1) |
| 731 | }) |
| 732 | } |
| 733 | |
| 734 | // when |
| 735 | responseV1 := PerformRequest(r, "GET", "/v1/test") |
| 736 | responseV2 := PerformRequest(r, "GET", "/v2/test") |
| 737 | |
| 738 | // then |
| 739 | assert.Equal(t, 200, responseV1.Code) |
| 740 | assert.Equal(t, 200, responseV2.Code) |
| 741 | assert.Equal(t, int64(2), handlerCounterV1) |
| 742 | assert.Equal(t, int64(2), middlewareCounterV1) |
| 743 | assert.Equal(t, int64(1), handlerCounterV2) |
| 744 | } |
| 745 | |
| 746 | func TestEngineHandleContextUseEscapedPathPercentEncoded(t *testing.T) { |
| 747 | r := New() |
nothing calls this directly
no test coverage detected