Test_Response_DecodeHelpers_ClientNilSafety() — fiber Function Reference
Architecture documentation for the Test_Response_DecodeHelpers_ClientNilSafety() function in response_test.go from the fiber codebase.
Entity Profile
Dependency Diagram
graph TD cf99eca7_6df5_012a_80e9_e6b6db57a6d5["Test_Response_DecodeHelpers_ClientNilSafety()"] 9a680627_ad54_340e_3faa_64ead9b39aef["response_test.go"] cf99eca7_6df5_012a_80e9_e6b6db57a6d5 -->|defined in| 9a680627_ad54_340e_3faa_64ead9b39aef style cf99eca7_6df5_012a_80e9_e6b6db57a6d5 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
client/response_test.go lines 455–573
func Test_Response_DecodeHelpers_ClientNilSafety(t *testing.T) {
t.Parallel()
t.Run("client nil returns exported error without panic", func(t *testing.T) {
t.Parallel()
type payload struct {
Status string `json:"status" xml:"status" cbor:"status"`
}
t.Run("json", func(t *testing.T) {
t.Parallel()
resp := AcquireResponse()
t.Cleanup(func() {
ReleaseResponse(resp)
})
resp.RawResponse.SetBodyString(`{"status":"success"}`)
decoded := payload{}
require.NotPanics(t, func() {
err := resp.JSON(&decoded)
require.ErrorIs(t, err, ErrClientNil)
})
})
t.Run("xml", func(t *testing.T) {
t.Parallel()
resp := AcquireResponse()
t.Cleanup(func() {
ReleaseResponse(resp)
})
resp.RawResponse.SetBodyString(`<payload><status>success</status></payload>`)
decoded := payload{}
require.NotPanics(t, func() {
err := resp.XML(&decoded)
require.ErrorIs(t, err, ErrClientNil)
})
})
t.Run("cbor", func(t *testing.T) {
t.Parallel()
resp := AcquireResponse()
t.Cleanup(func() {
ReleaseResponse(resp)
})
resp.RawResponse.SetBodyString("not-cbor")
decoded := payload{}
require.NotPanics(t, func() {
err := resp.CBOR(&decoded)
require.ErrorIs(t, err, ErrClientNil)
})
})
})
t.Run("decode helpers still work with client", func(t *testing.T) {
t.Parallel()
type payload struct {
Status string `json:"status" xml:"status" cbor:"status"`
}
t.Run("json", func(t *testing.T) {
t.Parallel()
resp := AcquireResponse()
t.Cleanup(func() {
ReleaseResponse(resp)
})
resp.setClient(New())
resp.RawResponse.SetBodyString(`{"status":"success"}`)
decoded := payload{}
err := resp.JSON(&decoded)
require.NoError(t, err)
require.Equal(t, "success", decoded.Status)
})
Domain
Subdomains
Defined In
Source
Frequently Asked Questions
What does Test_Response_DecodeHelpers_ClientNilSafety() do?
Test_Response_DecodeHelpers_ClientNilSafety() is a function in the fiber codebase, defined in client/response_test.go.
Where is Test_Response_DecodeHelpers_ClientNilSafety() defined?
Test_Response_DecodeHelpers_ClientNilSafety() is defined in client/response_test.go at line 455.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free