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

Function Test_Compress_Brotli

middleware/compress/compress_test.go:123–145  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

121}
122
123func Test_Compress_Brotli(t *testing.T) {
124 t.Parallel()
125 app := fiber.New()
126
127 app.Use(New())
128
129 app.Get("/", func(c fiber.Ctx) error {
130 return c.Send(filedata)
131 })
132
133 req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
134 req.Header.Set("Accept-Encoding", "br")
135
136 resp, err := app.Test(req, testConfig)
137 require.NoError(t, err, "app.Test(req)")
138 require.Equal(t, 200, resp.StatusCode, "Status code")
139 require.Equal(t, "br", resp.Header.Get(fiber.HeaderContentEncoding))
140
141 // Validate that the file size has shrunk
142 body, err := io.ReadAll(resp.Body)
143 require.NoError(t, err)
144 require.Less(t, len(body), len(filedata))
145}
146
147func Test_Compress_Zstd(t *testing.T) {
148 t.Parallel()

Callers

nothing calls this directly

Calls 8

TestMethod · 0.80
NewFunction · 0.70
NewMethod · 0.65
UseMethod · 0.65
GetMethod · 0.65
SendMethod · 0.65
SetMethod · 0.65
LessMethod · 0.45

Tested by

no test coverage detected