(t *testing.T)
| 543 | } |
| 544 | |
| 545 | func TestSchemeHostPath(t *testing.T) { |
| 546 | tests := []routeTest{ |
| 547 | { |
| 548 | title: "Host and Path route, match", |
| 549 | route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), |
| 550 | request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), |
| 551 | vars: map[string]string{}, |
| 552 | scheme: "http", |
| 553 | host: "aaa.bbb.ccc", |
| 554 | path: "/111/222/333", |
| 555 | pathTemplate: `/111/222/333`, |
| 556 | hostTemplate: `aaa.bbb.ccc`, |
| 557 | shouldMatch: true, |
| 558 | }, |
| 559 | { |
| 560 | title: "Scheme, Host, and Path route, match", |
| 561 | route: new(Route).Schemes("https").Host("aaa.bbb.ccc").Path("/111/222/333"), |
| 562 | request: newRequest("GET", "https://aaa.bbb.ccc/111/222/333"), |
| 563 | vars: map[string]string{}, |
| 564 | scheme: "https", |
| 565 | host: "aaa.bbb.ccc", |
| 566 | path: "/111/222/333", |
| 567 | pathTemplate: `/111/222/333`, |
| 568 | hostTemplate: `aaa.bbb.ccc`, |
| 569 | shouldMatch: true, |
| 570 | }, |
| 571 | { |
| 572 | title: "Host and Path route, wrong host in request URL", |
| 573 | route: new(Route).Host("aaa.bbb.ccc").Path("/111/222/333"), |
| 574 | request: newRequest("GET", "http://aaa.222.ccc/111/222/333"), |
| 575 | vars: map[string]string{}, |
| 576 | scheme: "http", |
| 577 | host: "aaa.bbb.ccc", |
| 578 | path: "/111/222/333", |
| 579 | pathTemplate: `/111/222/333`, |
| 580 | hostTemplate: `aaa.bbb.ccc`, |
| 581 | shouldMatch: false, |
| 582 | }, |
| 583 | { |
| 584 | title: "Host and Path route with pattern, match", |
| 585 | route: new(Route).Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), |
| 586 | request: newRequest("GET", "http://aaa.bbb.ccc/111/222/333"), |
| 587 | vars: map[string]string{"v1": "bbb", "v2": "222"}, |
| 588 | scheme: "http", |
| 589 | host: "aaa.bbb.ccc", |
| 590 | path: "/111/222/333", |
| 591 | pathTemplate: `/111/{v2:[0-9]{3}}/333`, |
| 592 | hostTemplate: `aaa.{v1:[a-z]{3}}.ccc`, |
| 593 | shouldMatch: true, |
| 594 | }, |
| 595 | { |
| 596 | title: "Scheme, Host, and Path route with host and path patterns, match", |
| 597 | route: new(Route).Schemes("ftp", "ssss").Host("aaa.{v1:[a-z]{3}}.ccc").Path("/111/{v2:[0-9]{3}}/333"), |
| 598 | request: newRequest("GET", "ssss://aaa.bbb.ccc/111/222/333"), |
| 599 | vars: map[string]string{"v1": "bbb", "v2": "222"}, |
| 600 | scheme: "ftp", |
| 601 | host: "aaa.bbb.ccc", |
| 602 | path: "/111/222/333", |
nothing calls this directly
no test coverage detected