MCPcopy
hub / github.com/gorilla/mux / TestSkipClean

Function TestSkipClean

mux_test.go:1985–2001  ·  view source on GitHub ↗
(t *testing.T)

Source from the content-addressed store, hash-verified

1983}
1984
1985func TestSkipClean(t *testing.T) {
1986 func1 := func(w http.ResponseWriter, r *http.Request) {}
1987 func2 := func(w http.ResponseWriter, r *http.Request) {}
1988
1989 r := NewRouter()
1990 r.SkipClean(true)
1991 r.HandleFunc("/api/", func2).Name("func2")
1992 r.HandleFunc("/", func1).Name("func1")
1993
1994 req, _ := http.NewRequest("GET", "http://localhost//api/?abc=def", nil)
1995 res := NewRecorder()
1996 r.ServeHTTP(res, req)
1997
1998 if len(res.HeaderMap["Location"]) != 0 {
1999 t.Errorf("Shouldn't redirect since skip clean is disabled")
2000 }
2001}
2002
2003// https://plus.google.com/101022900381697718949/posts/eWy6DjFJ6uW
2004func TestSubrouterHeader(t *testing.T) {

Callers

nothing calls this directly

Calls 6

SkipCleanMethod · 0.95
HandleFuncMethod · 0.95
ServeHTTPMethod · 0.95
NewRouterFunction · 0.85
NewRecorderFunction · 0.85
NameMethod · 0.45

Tested by

no test coverage detected