mirror of
https://github.com/gin-gonic/gin.git
synced 2026-06-06 20:18:19 +08:00
fix(test): resolve concurrent testing.T usage, upgrade dependencies, and clean format rules
This commit is contained in:
parent
68e3a3d4fe
commit
376a4e23a1
@ -3872,14 +3872,25 @@ func BenchmarkGetMapFromFormData(b *testing.B) {
|
|||||||
func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
||||||
router := New()
|
router := New()
|
||||||
|
|
||||||
|
var mu sync.Mutex
|
||||||
|
var errs []string
|
||||||
|
|
||||||
router.GET("/user/:name", func(c *Context) {
|
router.GET("/user/:name", func(c *Context) {
|
||||||
name := c.Param("name")
|
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) {
|
router.GET("/files/*filepath", func(c *Context) {
|
||||||
filepath := c.Param("filepath")
|
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
|
var wg sync.WaitGroup
|
||||||
@ -3897,9 +3908,16 @@ func TestWildcardParamUnicodeConcurrency(t *testing.T) {
|
|||||||
req, _ := http.NewRequest(http.MethodGet, p, nil)
|
req, _ := http.NewRequest(http.MethodGet, p, nil)
|
||||||
w := httptest.NewRecorder()
|
w := httptest.NewRecorder()
|
||||||
router.ServeHTTP(w, req)
|
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()
|
wg.Wait()
|
||||||
|
|
||||||
|
assert.Empty(t, errs)
|
||||||
}
|
}
|
||||||
|
|||||||
2
go.mod
2
go.mod
@ -12,7 +12,7 @@ require (
|
|||||||
github.com/mattn/go-isatty v0.0.20
|
github.com/mattn/go-isatty v0.0.20
|
||||||
github.com/modern-go/reflect2 v1.0.2
|
github.com/modern-go/reflect2 v1.0.2
|
||||||
github.com/pelletier/go-toml/v2 v2.2.4
|
github.com/pelletier/go-toml/v2 v2.2.4
|
||||||
github.com/quic-go/quic-go v0.59.0
|
github.com/quic-go/quic-go v0.59.1
|
||||||
github.com/stretchr/testify v1.11.1
|
github.com/stretchr/testify v1.11.1
|
||||||
github.com/ugorji/go/codec v1.3.1
|
github.com/ugorji/go/codec v1.3.1
|
||||||
go.mongodb.org/mongo-driver/v2 v2.5.0
|
go.mongodb.org/mongo-driver/v2 v2.5.0
|
||||||
|
|||||||
4
go.sum
4
go.sum
@ -52,8 +52,8 @@ github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZb
|
|||||||
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
github.com/pmezard/go-difflib v1.0.0/go.mod h1:iKH77koFhYxTK1pcRnkKkqfTogsbg7gZNVY4sRDYZ/4=
|
||||||
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
github.com/quic-go/qpack v0.6.0 h1:g7W+BMYynC1LbYLSqRt8PBg5Tgwxn214ZZR34VIOjz8=
|
||||||
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
github.com/quic-go/qpack v0.6.0/go.mod h1:lUpLKChi8njB4ty2bFLX2x4gzDqXwUpaO1DP9qMDZII=
|
||||||
github.com/quic-go/quic-go v0.59.0 h1:OLJkp1Mlm/aS7dpKgTc6cnpynnD2Xg7C1pwL6vy/SAw=
|
github.com/quic-go/quic-go v0.59.1 h1:0Gmua0HW1Tv7ANR7hUYwRyD0MG5OJfgvYSZasGZzBic=
|
||||||
github.com/quic-go/quic-go v0.59.0/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
github.com/quic-go/quic-go v0.59.1/go.mod h1:upnsH4Ju1YkqpLXC305eW3yDZ4NfnNbmQRCMWS58IKU=
|
||||||
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
github.com/rogpeppe/go-internal v1.10.0 h1:TMyTOH3F/DB16zRVcYyreMH6GnZZrwQVAoYjRBZyWFQ=
|
||||||
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
github.com/rogpeppe/go-internal v1.10.0/go.mod h1:UQnix2H7Ngw/k4C5ijL5+65zddjncjaFoBhdsK/akog=
|
||||||
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
github.com/stretchr/objx v0.1.0/go.mod h1:HFkY916IF+rwdDfMAkV7OtwuqBVzrE8GR6GFx+wExME=
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user