aboutsummaryrefslogtreecommitdiff
path: root/pkg/ext/compression_test.go
diff options
context:
space:
mode:
Diffstat (limited to 'pkg/ext/compression_test.go')
-rw-r--r--pkg/ext/compression_test.go42
1 files changed, 42 insertions, 0 deletions
diff --git a/pkg/ext/compression_test.go b/pkg/ext/compression_test.go
new file mode 100644
index 0000000..6424378
--- /dev/null
+++ b/pkg/ext/compression_test.go
@@ -0,0 +1,42 @@
+// go:build unit
+package ext
+
+import "testing"
+
+func TestGetCompression(t *testing.T) {
+ testCases := []struct {
+ name string
+ header string
+ compression string
+ }{
+ {
+ name: "Empty",
+ header: "",
+ compression: "*",
+ },
+ {
+ name: "Weighted",
+ header: "gzip;q=1.0, *;q=0.5",
+ compression: "gzip",
+ },
+ {
+ name: "Mixed",
+ header: "deflate, gzip;q=1.0, *;q=0.5",
+ compression: "deflate",
+ },
+ {
+ name: "Not weighted",
+ header: "zstd, deflate, gzip",
+ compression: "zstd",
+ },
+ }
+
+ for _, tc := range testCases {
+ t.Run(tc.name, func(t *testing.T) {
+ got := GetCompression(tc.header)
+ if got != tc.compression {
+ t.Errorf("Wrong compression returned: got %s want %s", got, tc.compression)
+ }
+ })
+ }
+}