github.com/prebid/prebid-server/v2@v2.18.0/config/compression_test.go (about) 1 package config 2 3 import ( 4 "testing" 5 6 "github.com/prebid/prebid-server/v2/util/httputil" 7 "github.com/stretchr/testify/assert" 8 ) 9 10 func TestReqCompressionCfgIsSupported(t *testing.T) { 11 testCases := []struct { 12 description string 13 cfg CompressionInfo 14 contentEncoding httputil.ContentEncoding 15 wantSupported bool 16 }{ 17 { 18 description: "Compression type not supported", 19 cfg: CompressionInfo{ 20 GZIP: true, 21 }, 22 contentEncoding: httputil.ContentEncoding("invalid"), 23 wantSupported: false, 24 }, 25 { 26 description: "Compression type supported", 27 cfg: CompressionInfo{ 28 GZIP: true, 29 }, 30 contentEncoding: httputil.ContentEncodingGZIP, 31 wantSupported: true, 32 }, 33 { 34 description: "Compression not enabled", 35 cfg: CompressionInfo{ 36 GZIP: false, 37 }, 38 contentEncoding: httputil.ContentEncodingGZIP, 39 wantSupported: false, 40 }, 41 } 42 43 for _, test := range testCases { 44 got := test.cfg.IsSupported(test.contentEncoding) 45 assert.Equal(t, got, test.wantSupported, test.description) 46 } 47 }