mirror of
https://github.com/gin-gonic/gin.git
synced 2026-07-14 23:21:18 +08:00
test(context): add tests for GetError and GetErrorSlice handling missing keys
This commit is contained in:
parent
71a2b2f85a
commit
e4f4d5fb92
@ -522,6 +522,9 @@ func TestContextGetError(t *testing.T) {
|
||||
value := errors.New("test error")
|
||||
c.Set(key, value)
|
||||
assert.Equal(t, value, c.GetError(key))
|
||||
|
||||
// Test missing key returns nil
|
||||
assert.Nil(t, c.GetError("missing"))
|
||||
}
|
||||
|
||||
func TestContextGetIntSlice(t *testing.T) {
|
||||
@ -632,6 +635,9 @@ func TestContextGetErrorSlice(t *testing.T) {
|
||||
value := []error{errors.New("error1"), errors.New("error2")}
|
||||
c.Set(key, value)
|
||||
assert.Equal(t, value, c.GetErrorSlice(key))
|
||||
|
||||
// Test missing key returns nil slice
|
||||
assert.Nil(t, c.GetErrorSlice("missing"))
|
||||
}
|
||||
|
||||
func TestContextGetStringMap(t *testing.T) {
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user