(t *testing.T)
| 476 | } |
| 477 | |
| 478 | func TestSetRequestUrlFromRequest(t *testing.T) { |
| 479 | for _, ti := range []struct { |
| 480 | msg string |
| 481 | originalURL *url.URL |
| 482 | expectedURL *url.URL |
| 483 | req *http.Request |
| 484 | }{{ |
| 485 | "Scheme and Host are set when empty", |
| 486 | &url.URL{Scheme: "", Host: ""}, |
| 487 | &url.URL{Scheme: "http", Host: "example.com"}, |
| 488 | &http.Request{TLS: nil, Host: "example.com"}, |
| 489 | }, { |
| 490 | "Scheme and Host are not modified when already set", |
| 491 | &url.URL{Scheme: "http", Host: "example.com"}, |
| 492 | &url.URL{Scheme: "http", Host: "example.com"}, |
| 493 | &http.Request{TLS: &tls.ConnectionState{}, Host: "example2.com"}, |
| 494 | }, { |
| 495 | "Scheme is set to http when TLS not set", |
| 496 | &url.URL{Scheme: ""}, |
| 497 | &url.URL{Scheme: "http"}, |
| 498 | &http.Request{TLS: nil}, |
| 499 | }, { |
| 500 | "Scheme is set to https when TLS is set", |
| 501 | &url.URL{Scheme: ""}, |
| 502 | &url.URL{Scheme: "https"}, |
| 503 | &http.Request{TLS: &tls.ConnectionState{}}, |
| 504 | }} { |
| 505 | u, _ := url.Parse(ti.originalURL.String()) |
| 506 | setRequestURLFromRequest(u, ti.req) |
| 507 | |
| 508 | beq := reflect.DeepEqual(ti.expectedURL, u) |
| 509 | if !beq { |
| 510 | t.Error(ti.msg, "<urls don't match>", ti.expectedURL, u) |
| 511 | } |
| 512 | } |
| 513 | } |
| 514 | |
| 515 | func TestSetRequestUrlForDynamicBackend(t *testing.T) { |
| 516 | for _, ti := range []struct { |
nothing calls this directly
no test coverage detected
searching dependent graphs…