(t *testing.T)
| 390 | } |
| 391 | |
| 392 | func TestProxy_UpdateCacheHeaders(t *testing.T) { |
| 393 | date := "Mon, 02 Jan 2006 15:04:05 MST" |
| 394 | exp := "Mon, 02 Jan 2006 16:04:05 MST" |
| 395 | |
| 396 | tests := []struct { |
| 397 | name string |
| 398 | minDuration time.Duration |
| 399 | forceCache bool |
| 400 | headers http.Header |
| 401 | want http.Header |
| 402 | }{ |
| 403 | { |
| 404 | name: "zero", |
| 405 | headers: http.Header{}, |
| 406 | want: http.Header{}, |
| 407 | }, |
| 408 | { |
| 409 | name: "no min duration", |
| 410 | headers: http.Header{ |
| 411 | "Date": {date}, |
| 412 | "Expires": {exp}, |
| 413 | "Cache-Control": {"max-age=600"}, |
| 414 | }, |
| 415 | want: http.Header{ |
| 416 | "Date": {date}, |
| 417 | "Expires": {exp}, |
| 418 | "Cache-Control": {"max-age=600"}, |
| 419 | }, |
| 420 | }, |
| 421 | { |
| 422 | name: "min duration, no header", |
| 423 | minDuration: 30 * time.Second, |
| 424 | headers: http.Header{}, |
| 425 | want: http.Header{ |
| 426 | "Cache-Control": {"max-age=30"}, |
| 427 | }, |
| 428 | }, |
| 429 | { |
| 430 | name: "cache control exceeds min duration", |
| 431 | minDuration: 30 * time.Second, |
| 432 | headers: http.Header{ |
| 433 | "Cache-Control": {"max-age=600"}, |
| 434 | }, |
| 435 | want: http.Header{ |
| 436 | "Cache-Control": {"max-age=600"}, |
| 437 | }, |
| 438 | }, |
| 439 | { |
| 440 | name: "cache control exceeds min duration, expires", |
| 441 | minDuration: 30 * time.Second, |
| 442 | headers: http.Header{ |
| 443 | "Date": {date}, |
| 444 | "Expires": {exp}, |
| 445 | "Cache-Control": {"max-age=86400"}, |
| 446 | }, |
| 447 | want: http.Header{ |
| 448 | "Date": {date}, |
| 449 | "Cache-Control": {"max-age=86400"}, |
nothing calls this directly
no test coverage detected