(t *testing.T)
| 513 | } |
| 514 | |
| 515 | func TestSetRequestUrlForDynamicBackend(t *testing.T) { |
| 516 | for _, ti := range []struct { |
| 517 | msg string |
| 518 | expectedURL *url.URL |
| 519 | stateBag map[string]interface{} |
| 520 | }{{ |
| 521 | "DynamicBackendURLKey is set", |
| 522 | &url.URL{Scheme: "https", Host: "example.com"}, |
| 523 | map[string]interface{}{filters.DynamicBackendURLKey: "https://example.com"}, |
| 524 | }, { |
| 525 | "DynamicBackendURLKey is set with not url", |
| 526 | &url.URL{}, |
| 527 | map[string]interface{}{filters.DynamicBackendURLKey: "some string"}, |
| 528 | }, { |
| 529 | "DynamicBackendHostKey is set", |
| 530 | &url.URL{Host: "example.com"}, |
| 531 | map[string]interface{}{filters.DynamicBackendHostKey: "example.com"}, |
| 532 | }, { |
| 533 | "DynamicBackendSchemeKey is set", |
| 534 | &url.URL{Scheme: "http"}, |
| 535 | map[string]interface{}{filters.DynamicBackendSchemeKey: "http"}, |
| 536 | }, { |
| 537 | "All keys are set, DynamicBackendURLKey has priority", |
| 538 | &url.URL{Scheme: "https", Host: "priority.com"}, |
| 539 | map[string]interface{}{ |
| 540 | filters.DynamicBackendSchemeKey: "http", |
| 541 | filters.DynamicBackendHostKey: "example.com", |
| 542 | filters.DynamicBackendURLKey: "https://priority.com"}, |
| 543 | }} { |
| 544 | u := &url.URL{} |
| 545 | setRequestURLForDynamicBackend(u, ti.stateBag) |
| 546 | |
| 547 | beq := reflect.DeepEqual(ti.expectedURL, u) |
| 548 | if !beq { |
| 549 | t.Error(ti.msg, "<urls don't match>", ti.expectedURL, u) |
| 550 | } |
| 551 | } |
| 552 | } |
| 553 | |
| 554 | func TestGetRoundtripForDynamicBackend(t *testing.T) { |
| 555 | payload := []byte("Hello World!") |
nothing calls this directly
no test coverage detected
searching dependent graphs…