// 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) } }) } }