1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62
|
Description: Fix test failure with Go 1.10
Author: Rebecca Stambler <rstambler@golang.org>
Origin: vendor, https://github.com/julienschmidt/httprouter/commit/0b0afca848ce5cf472a0dbb426b54e5cdb630f16
Last-Update: 2018-02-16
---
From 0b0afca848ce5cf472a0dbb426b54e5cdb630f16 Mon Sep 17 00:00:00 2001
From: Rebecca Stambler <rstambler@golang.org>
Date: Fri, 27 Oct 2017 09:33:06 -0400
Subject: [PATCH] router_test.go: fix to handle changes to Content-Type header
(#220)
---
router_test.go | 28 ++++++++++++++--------------
1 file changed, 14 insertions(+), 14 deletions(-)
diff --git a/router_test.go b/router_test.go
index fe58c8a..b774a4e 100644
--- a/router_test.go
+++ b/router_test.go
@@ -364,26 +364,26 @@ func TestRouterNotFound(t *testing.T) {
router.GET("/", handlerFunc)
testRoutes := []struct {
- route string
- code int
- header string
+ route string
+ code int
+ location string
}{
- {"/path/", 301, "map[Location:[/path]]"}, // TSR -/
- {"/dir", 301, "map[Location:[/dir/]]"}, // TSR +/
- {"", 301, "map[Location:[/]]"}, // TSR +/
- {"/PATH", 301, "map[Location:[/path]]"}, // Fixed Case
- {"/DIR/", 301, "map[Location:[/dir/]]"}, // Fixed Case
- {"/PATH/", 301, "map[Location:[/path]]"}, // Fixed Case -/
- {"/DIR", 301, "map[Location:[/dir/]]"}, // Fixed Case +/
- {"/../path", 301, "map[Location:[/path]]"}, // CleanPath
- {"/nope", 404, ""}, // NotFound
+ {"/path/", 301, "/path"}, // TSR -/
+ {"/dir", 301, "/dir/"}, // TSR +/
+ {"", 301, "/"}, // TSR +/
+ {"/PATH", 301, "/path"}, // Fixed Case
+ {"/DIR/", 301, "/dir/"}, // Fixed Case
+ {"/PATH/", 301, "/path"}, // Fixed Case -/
+ {"/DIR", 301, "/dir/"}, // Fixed Case +/
+ {"/../path", 301, "/path"}, // CleanPath
+ {"/nope", 404, ""}, // NotFound
}
for _, tr := range testRoutes {
r, _ := http.NewRequest("GET", tr.route, nil)
w := httptest.NewRecorder()
router.ServeHTTP(w, r)
- if !(w.Code == tr.code && (w.Code == 404 || fmt.Sprint(w.Header()) == tr.header)) {
- t.Errorf("NotFound handling route %s failed: Code=%d, Header=%v", tr.route, w.Code, w.Header())
+ if !(w.Code == tr.code && (w.Code == 404 || fmt.Sprint(w.Header().Get("Location")) == tr.location)) {
+ t.Errorf("NotFound handling route %s failed: Code=%d, Header=%v", tr.route, w.Code, w.Header().Get("Location"))
}
}
|