diff options
author | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-07 19:33:07 +0200 |
---|---|---|
committer | Gabriel A. Giovanini <mail@gabrielgio.me> | 2024-06-07 19:33:07 +0200 |
commit | c7a8aa113a914e70e027fea93265c7232b865b5e (patch) | |
tree | d5514cb6e5f49838ff75e814b64652ad244cf0ef /pkg/ext/compression_test.go | |
parent | 18aa098f50e2a2c7db01dd4d04dde460fd40f5d5 (diff) | |
download | cerrado-c7a8aa113a914e70e027fea93265c7232b865b5e.tar.gz cerrado-c7a8aa113a914e70e027fea93265c7232b865b5e.tar.bz2 cerrado-c7a8aa113a914e70e027fea93265c7232b865b5e.zip |
feat: Add compression
Diffstat (limited to 'pkg/ext/compression_test.go')
-rw-r--r-- | pkg/ext/compression_test.go | 42 |
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) + } + }) + } +} |