(t *testing.T)
| 256 | } |
| 257 | |
| 258 | func TestIsEncodeAllowed(t *testing.T) { |
| 259 | testCases := []struct { |
| 260 | name string |
| 261 | headers http.Header |
| 262 | expected bool |
| 263 | }{ |
| 264 | { |
| 265 | name: "Without any headers", |
| 266 | headers: http.Header{}, |
| 267 | expected: true, |
| 268 | }, |
| 269 | { |
| 270 | name: "Without Cache-Control HTTP header", |
| 271 | headers: http.Header{ |
| 272 | "Accept-Encoding": {"gzip"}, |
| 273 | }, |
| 274 | expected: true, |
| 275 | }, |
| 276 | { |
| 277 | name: "Cache-Control HTTP header ending with no-transform directive", |
| 278 | headers: http.Header{ |
| 279 | "Accept-Encoding": {"gzip"}, |
| 280 | "Cache-Control": {"no-cache; no-transform"}, |
| 281 | }, |
| 282 | expected: false, |
| 283 | }, |
| 284 | { |
| 285 | name: "With Cache-Control HTTP header no-transform as Cache-Extension value", |
| 286 | headers: http.Header{ |
| 287 | "Accept-Encoding": {"gzip"}, |
| 288 | "Cache-Control": {`no-store; no-cache; community="no-transform"`}, |
| 289 | }, |
| 290 | expected: false, |
| 291 | }, |
| 292 | } |
| 293 | |
| 294 | for _, test := range testCases { |
| 295 | t.Run(test.name, func(t *testing.T) { |
| 296 | if result := isEncodeAllowed(test.headers); result != test.expected { |
| 297 | t.Errorf("The headers given to the isEncodeAllowed should return %t, %t given.", |
| 298 | result, |
| 299 | test.expected) |
| 300 | } |
| 301 | }) |
| 302 | } |
| 303 | } |
| 304 | |
| 305 | type mockEncoder struct{} |
| 306 |
nothing calls this directly
no test coverage detected