mirror of
https://github.com/gin-gonic/gin.git
synced 2025-10-18 23:12:17 +08:00
Add unit testing.
Signed-off-by: Bo-Yi Wu <appleboy.tw@gmail.com>
This commit is contained in:
parent
ba621af762
commit
fdebef2da9
@ -1918,3 +1918,16 @@ func TestRaceParamsContextCopy(t *testing.T) {
|
|||||||
performRequest(router, "GET", "/name2/api")
|
performRequest(router, "GET", "/name2/api")
|
||||||
wg.Wait()
|
wg.Wait()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func TestContextWithKeysMutex(t *testing.T) {
|
||||||
|
c := &Context{}
|
||||||
|
c.Set("foo", "bar")
|
||||||
|
|
||||||
|
value, err := c.Get("foo")
|
||||||
|
assert.Equal(t, "bar", value)
|
||||||
|
assert.True(t, err)
|
||||||
|
|
||||||
|
value, err = c.Get("foo2")
|
||||||
|
assert.Nil(t, value)
|
||||||
|
assert.False(t, err)
|
||||||
|
}
|
||||||
|
1
go.sum
1
go.sum
@ -1,4 +1,5 @@
|
|||||||
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
|
github.com/davecgh/go-spew v1.1.1 h1:vj9j/u1bqnvCEfJOwUhtlOARqs3+rkHYY13jYWTU97c=
|
||||||
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
github.com/davecgh/go-spew v1.1.1/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
|
||||||
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
github.com/gin-contrib/sse v0.1.0 h1:Y/yl/+YNO8GZSjAhjMsSuLt29uWRFHdHYUb5lYOV9qE=
|
||||||
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
github.com/gin-contrib/sse v0.1.0/go.mod h1:RHrZQHXnP2xjPF+u1gW/2HnVO7nvIa9PG3Gm+fLHvGI=
|
||||||
|
Loading…
x
Reference in New Issue
Block a user