(t *testing.T)
| 227 | } |
| 228 | |
| 229 | func TestPath(t *testing.T) { |
| 230 | tests := []routeTest{ |
| 231 | { |
| 232 | title: "Path route, match", |
| 233 | route: new(Route).Path("/111/222/333"), |
| 234 | request: newRequest("GET", "http://localhost/111/222/333"), |
| 235 | vars: map[string]string{}, |
| 236 | host: "", |
| 237 | path: "/111/222/333", |
| 238 | shouldMatch: true, |
| 239 | }, |
| 240 | { |
| 241 | title: "Path route, match with trailing slash in request and path", |
| 242 | route: new(Route).Path("/111/"), |
| 243 | request: newRequest("GET", "http://localhost/111/"), |
| 244 | vars: map[string]string{}, |
| 245 | host: "", |
| 246 | path: "/111/", |
| 247 | shouldMatch: true, |
| 248 | }, |
| 249 | { |
| 250 | title: "Path route, do not match with trailing slash in path", |
| 251 | route: new(Route).Path("/111/"), |
| 252 | request: newRequest("GET", "http://localhost/111"), |
| 253 | vars: map[string]string{}, |
| 254 | host: "", |
| 255 | path: "/111", |
| 256 | pathTemplate: `/111/`, |
| 257 | pathRegexp: `^/111/$`, |
| 258 | shouldMatch: false, |
| 259 | }, |
| 260 | { |
| 261 | title: "Path route, do not match with trailing slash in request", |
| 262 | route: new(Route).Path("/111"), |
| 263 | request: newRequest("GET", "http://localhost/111/"), |
| 264 | vars: map[string]string{}, |
| 265 | host: "", |
| 266 | path: "/111/", |
| 267 | pathTemplate: `/111`, |
| 268 | shouldMatch: false, |
| 269 | }, |
| 270 | { |
| 271 | title: "Path route, match root with no host", |
| 272 | route: new(Route).Path("/"), |
| 273 | request: newRequest("GET", "/"), |
| 274 | vars: map[string]string{}, |
| 275 | host: "", |
| 276 | path: "/", |
| 277 | pathTemplate: `/`, |
| 278 | pathRegexp: `^/$`, |
| 279 | shouldMatch: true, |
| 280 | }, |
| 281 | { |
| 282 | title: "Path route, match root with no host, App Engine format", |
| 283 | route: new(Route).Path("/"), |
| 284 | request: func() *http.Request { |
| 285 | r := newRequest("GET", "http://localhost/") |
| 286 | r.RequestURI = "/" |
nothing calls this directly
no test coverage detected