compress_test.go — fiber Source File
Architecture documentation for compress_test.go, a go file in the fiber codebase. 1 imports, 0 dependents.
Entity Profile
Dependency Diagram
graph LR d6d930a5_a4c6_37a5_5df5_4b38486d6fe6["compress_test.go"] fcef1725_af89_d6cd_36cd_b228cdcc5acd["errors"] d6d930a5_a4c6_37a5_5df5_4b38486d6fe6 --> fcef1725_af89_d6cd_36cd_b228cdcc5acd style d6d930a5_a4c6_37a5_5df5_4b38486d6fe6 fill:#6366f1,stroke:#818cf8,color:#fff
Relationship Graph
Source Code
package compress
import (
"errors"
"fmt"
"io"
"net/http"
"net/http/httptest"
"os"
"testing"
"time"
"github.com/gofiber/fiber/v3"
"github.com/gofiber/fiber/v3/middleware/etag"
"github.com/stretchr/testify/require"
"github.com/valyala/fasthttp"
)
var filedata []byte
var testConfig = fiber.TestConfig{
Timeout: 10 * time.Second,
FailOnTimeout: true,
}
func init() {
dat, err := os.ReadFile("../../.github/README.md")
if err != nil {
panic(err)
}
filedata = dat
}
// go test -run Test_Compress_Gzip
func Test_Compress_Gzip(t *testing.T) {
t.Parallel()
app := fiber.New()
app.Use(New())
app.Get("/", func(c fiber.Ctx) error {
c.Set(fiber.HeaderContentType, fiber.MIMETextPlainCharsetUTF8)
return c.Send(filedata)
})
req := httptest.NewRequest(fiber.MethodGet, "/", http.NoBody)
req.Header.Set("Accept-Encoding", "gzip")
resp, err := app.Test(req, testConfig)
require.NoError(t, err, "app.Test(req)")
require.Equal(t, 200, resp.StatusCode, "Status code")
require.Equal(t, "gzip", resp.Header.Get(fiber.HeaderContentEncoding))
// Validate that the file size has shrunk
body, err := io.ReadAll(resp.Body)
require.NoError(t, err)
require.Less(t, len(body), len(filedata))
}
// go test -run Test_Compress_Different_Level
// ... (801 more lines)
Domain
Subdomains
Functions
- Benchmark_Compress()
- Benchmark_Compress_Levels()
- Benchmark_Compress_Levels_Parallel()
- Benchmark_Compress_Parallel()
- Test_Compress_Adds_Vary_Header()
- Test_Compress_Brotli()
- Test_Compress_Deflate()
- Test_Compress_Different_Level()
- Test_Compress_Disabled()
- Test_Compress_Gzip()
- Test_Compress_Next()
- Test_Compress_Next_Error()
- Test_Compress_Skip_Head()
- Test_Compress_Skip_NoTransform()
- Test_Compress_Skip_Range()
- Test_Compress_Skip_Range_NoAcceptEncoding()
- Test_Compress_Skip_Range_Vary_Similar_Substring()
- Test_Compress_Skip_Range_Vary_Star()
- Test_Compress_Skip_Status_NoContent()
- Test_Compress_Skip_Status_NotModified()
- Test_Compress_Skip_Status_PartialContent()
- Test_Compress_Skip_When_Content_Encoding_Set()
- Test_Compress_Skip_When_Content_Encoding_Set_Vary_List_Star()
- Test_Compress_Skip_When_Content_Encoding_Set_Vary_Similar_Substring()
- Test_Compress_Skip_When_Content_Encoding_Set_Vary_Star()
- Test_Compress_Strong_ETag_Recalculated()
- Test_Compress_Strong_ETag_Unchanged_When_Not_Compressed()
- Test_Compress_Vary_List_Star()
- Test_Compress_Vary_Similar_Substring()
- Test_Compress_Vary_Star()
- Test_Compress_Weak_ETag_Unchanged()
- Test_Compress_Zstd()
- init()
Classes
Types
Dependencies
- errors
Source
Frequently Asked Questions
What does compress_test.go do?
compress_test.go is a source file in the fiber codebase, written in go. It belongs to the FiberCore domain, Adapters subdomain.
What functions are defined in compress_test.go?
compress_test.go defines 33 function(s): Benchmark_Compress, Benchmark_Compress_Levels, Benchmark_Compress_Levels_Parallel, Benchmark_Compress_Parallel, Test_Compress_Adds_Vary_Header, Test_Compress_Brotli, Test_Compress_Deflate, Test_Compress_Different_Level, Test_Compress_Disabled, Test_Compress_Gzip, and 23 more.
What does compress_test.go depend on?
compress_test.go imports 1 module(s): errors.
Where is compress_test.go in the architecture?
compress_test.go is located at middleware/compress/compress_test.go (domain: FiberCore, subdomain: Adapters, directory: middleware/compress).
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free