mirror of
https://github.com/gin-gonic/gin.git
synced 2026-09-04 14:49:27 +08:00
fix(test): resolve concurrent testing.T usage, upgrade dependencies, and clean format rules
This commit is contained in:
parent
7a0e3d902f
commit
ce65d64ef5
@ -3958,15 +3958,26 @@ func BenchmarkGetMapFromFormData(b *testing.B) {
|
||||
|
||||
func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
||||
router := New()
|
||||
|
||||
|
||||
var mu sync.Mutex
|
||||
var errs []string
|
||||
|
||||
router.GET("/user/:name", func(c *Context) {
|
||||
name := c.Param("name")
|
||||
assert.NotEmpty(t, name)
|
||||
if name == "" {
|
||||
mu.Lock()
|
||||
errs = append(errs, "name param is empty")
|
||||
mu.Unlock()
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
router.GET("/files/*filepath", func(c *Context) {
|
||||
filepath := c.Param("filepath")
|
||||
assert.NotEmpty(t, filepath)
|
||||
if filepath == "" {
|
||||
mu.Lock()
|
||||
errs = append(errs, "filepath param is empty")
|
||||
mu.Unlock()
|
||||
}
|
||||
})
|
||||
|
||||
var wg sync.WaitGroup
|
||||
@ -3984,9 +3995,16 @@ func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
||||
req, _ := http.NewRequest(http.MethodGet, p, nil)
|
||||
w := httptest.NewRecorder()
|
||||
router.ServeHTTP(w, req)
|
||||
assert.Equal(t, http.StatusOK, w.Code)
|
||||
|
||||
if w.Code != http.StatusOK {
|
||||
mu.Lock()
|
||||
errs = append(errs, "status code is not 200")
|
||||
mu.Unlock()
|
||||
}
|
||||
}
|
||||
}()
|
||||
}
|
||||
wg.Wait()
|
||||
|
||||
assert.Empty(t, errs)
|
||||
}
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user