(t *testing.T)
| 1075 | } |
| 1076 | |
| 1077 | func TestSchemes(t *testing.T) { |
| 1078 | tests := []routeTest{ |
| 1079 | // Schemes |
| 1080 | { |
| 1081 | title: "Schemes route, default scheme, match http, build http", |
| 1082 | route: new(Route).Host("localhost"), |
| 1083 | request: newRequest("GET", "http://localhost"), |
| 1084 | scheme: "http", |
| 1085 | host: "localhost", |
| 1086 | shouldMatch: true, |
| 1087 | }, |
| 1088 | { |
| 1089 | title: "Schemes route, match https, build https", |
| 1090 | route: new(Route).Schemes("https", "ftp").Host("localhost"), |
| 1091 | request: newRequest("GET", "https://localhost"), |
| 1092 | scheme: "https", |
| 1093 | host: "localhost", |
| 1094 | shouldMatch: true, |
| 1095 | }, |
| 1096 | { |
| 1097 | title: "Schemes route, match ftp, build https", |
| 1098 | route: new(Route).Schemes("https", "ftp").Host("localhost"), |
| 1099 | request: newRequest("GET", "ftp://localhost"), |
| 1100 | scheme: "https", |
| 1101 | host: "localhost", |
| 1102 | shouldMatch: true, |
| 1103 | }, |
| 1104 | { |
| 1105 | title: "Schemes route, match ftp, build ftp", |
| 1106 | route: new(Route).Schemes("ftp", "https").Host("localhost"), |
| 1107 | request: newRequest("GET", "ftp://localhost"), |
| 1108 | scheme: "ftp", |
| 1109 | host: "localhost", |
| 1110 | shouldMatch: true, |
| 1111 | }, |
| 1112 | { |
| 1113 | title: "Schemes route, bad scheme", |
| 1114 | route: new(Route).Schemes("https", "ftp").Host("localhost"), |
| 1115 | request: newRequest("GET", "http://localhost"), |
| 1116 | scheme: "https", |
| 1117 | host: "localhost", |
| 1118 | shouldMatch: false, |
| 1119 | }, |
| 1120 | } |
| 1121 | for _, test := range tests { |
| 1122 | t.Run(test.title, func(t *testing.T) { |
| 1123 | testRoute(t, test) |
| 1124 | testTemplate(t, test) |
| 1125 | }) |
| 1126 | } |
| 1127 | } |
| 1128 | |
| 1129 | func TestMatcherFunc(t *testing.T) { |
| 1130 | m := func(r *http.Request, m *RouteMatch) bool { |
nothing calls this directly
no test coverage detected