Browse Source

Add test for `SkipClean`

pull/154/head
Jingwen Owen Ou 10 years ago
parent
commit
9935257381
  1. 18
      mux_test.go

18
mux_test.go

@ -1376,6 +1376,24 @@ func Test301Redirect(t *testing.T) { @@ -1376,6 +1376,24 @@ func Test301Redirect(t *testing.T) {
}
}
func TestSkipClean(t *testing.T) {
func1 := func(w http.ResponseWriter, r *http.Request) {}
func2 := func(w http.ResponseWriter, r *http.Request) {}
r := NewRouter()
r.SkipClean(true)
r.HandleFunc("/api/", func2).Name("func2")
r.HandleFunc("/", func1).Name("func1")
req, _ := http.NewRequest("GET", "http://localhost//api/?abc=def", nil)
res := NewRecorder()
r.ServeHTTP(res, req)
if len(res.HeaderMap["Location"]) != 0 {
t.Errorf("Shouldn't redirect since skip clean is disabled")
}
}
// https://plus.google.com/101022900381697718949/posts/eWy6DjFJ6uW
func TestSubrouterHeader(t *testing.T) {
expected := "func1 response"

Loading…
Cancel
Save