fix(test): only check Location header (#1064)
* fix(test): only check Location header * fix(test): rename field * fix(test): not export field
This commit is contained in:
parent
81007d2ce0
commit
4b5ec517da
@ -356,25 +356,25 @@ func TestRouterNotFound(t *testing.T) {
|
|||||||
router.GET("/", func(c *Context) {})
|
router.GET("/", func(c *Context) {})
|
||||||
|
|
||||||
testRoutes := []struct {
|
testRoutes := []struct {
|
||||||
route string
|
route string
|
||||||
code int
|
code int
|
||||||
header string
|
location string
|
||||||
}{
|
}{
|
||||||
{"/path/", 301, "map[Location:[/path]]"}, // TSR -/
|
{"/path/", 301, "/path"}, // TSR -/
|
||||||
{"/dir", 301, "map[Location:[/dir/]]"}, // TSR +/
|
{"/dir", 301, "/dir/"}, // TSR +/
|
||||||
{"", 301, "map[Location:[/]]"}, // TSR +/
|
{"", 301, "/"}, // TSR +/
|
||||||
{"/PATH", 301, "map[Location:[/path]]"}, // Fixed Case
|
{"/PATH", 301, "/path"}, // Fixed Case
|
||||||
{"/DIR/", 301, "map[Location:[/dir/]]"}, // Fixed Case
|
{"/DIR/", 301, "/dir/"}, // Fixed Case
|
||||||
{"/PATH/", 301, "map[Location:[/path]]"}, // Fixed Case -/
|
{"/PATH/", 301, "/path"}, // Fixed Case -/
|
||||||
{"/DIR", 301, "map[Location:[/dir/]]"}, // Fixed Case +/
|
{"/DIR", 301, "/dir/"}, // Fixed Case +/
|
||||||
{"/../path", 301, "map[Location:[/path]]"}, // CleanPath
|
{"/../path", 301, "/path"}, // CleanPath
|
||||||
{"/nope", 404, ""}, // NotFound
|
{"/nope", 404, ""}, // NotFound
|
||||||
}
|
}
|
||||||
for _, tr := range testRoutes {
|
for _, tr := range testRoutes {
|
||||||
w := performRequest(router, "GET", tr.route)
|
w := performRequest(router, "GET", tr.route)
|
||||||
assert.Equal(t, w.Code, tr.code)
|
assert.Equal(t, w.Code, tr.code)
|
||||||
if w.Code != 404 {
|
if w.Code != 404 {
|
||||||
assert.Equal(t, fmt.Sprint(w.Header()), tr.header)
|
assert.Equal(t, fmt.Sprint(w.Header().Get("Location")), tr.location)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user