MCPcopy
hub / github.com/gofiber/fiber / Test_Request_Error_Body_With_Server

Function Test_Request_Error_Body_With_Server

client/request_test.go:1522–1570  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1520}
1521
1522func Test_Request_Error_Body_With_Server(t *testing.T) {
1523 t.Parallel()
1524 t.Run("json error", func(t *testing.T) {
1525 t.Parallel()
1526 testRequestFail(
1527 t,
1528 func(c fiber.Ctx) error {
1529 return c.SendString("")
1530 },
1531 func(agent *Request) {
1532 agent.SetJSON(complex(1, 1))
1533 },
1534 errors.New("json: unsupported type: complex128"),
1535 )
1536 })
1537
1538 t.Run("xml error", func(t *testing.T) {
1539 t.Parallel()
1540 testRequestFail(
1541 t,
1542 func(c fiber.Ctx) error {
1543 return c.SendString("")
1544 },
1545 func(agent *Request) {
1546 agent.SetXML(complex(1, 1))
1547 },
1548 errors.New("xml: unsupported type: complex128"),
1549 )
1550 })
1551
1552 t.Run("form body with invalid boundary", func(t *testing.T) {
1553 t.Parallel()
1554
1555 _, err := AcquireRequest().
1556 SetBoundary("*").
1557 AddFileWithReader("t.txt", io.NopCloser(strings.NewReader("world"))).
1558 Get("http://example.com")
1559 require.Equal(t, "set boundary error: mime: invalid boundary character", err.Error())
1560 })
1561
1562 t.Run("open non exist file", func(t *testing.T) {
1563 t.Parallel()
1564
1565 _, err := AcquireRequest().
1566 AddFile("non-exist-file!").
1567 Get("http://example.com")
1568 require.Contains(t, err.Error(), "open non-exist-file!")
1569 })
1570}
1571
1572func Test_Request_Timeout_With_Server(t *testing.T) {
1573 t.Parallel()

Callers

nothing calls this directly

Calls 12

testRequestFailFunction · 0.85
AcquireRequestFunction · 0.85
AddFileWithReaderMethod · 0.80
SetBoundaryMethod · 0.80
AddFileMethod · 0.80
ContainsMethod · 0.80
SendStringMethod · 0.65
NewMethod · 0.65
GetMethod · 0.65
ErrorMethod · 0.65
SetJSONMethod · 0.45
SetXMLMethod · 0.45

Tested by

no test coverage detected