From 17227c10c48acd3a82984f3009f0cd436ac2b72b Mon Sep 17 00:00:00 2001 From: Carl Jackson Date: Sun, 2 Nov 2014 13:01:32 -0800 Subject: [PATCH] Improve test coverage slightly --- web/router_test.go | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/web/router_test.go b/web/router_test.go index b80862d..44dabf5 100644 --- a/web/router_test.go +++ b/web/router_test.go @@ -306,4 +306,21 @@ func TestValidMethods(t *testing.T) { aMethods) } } + + // This should also work when c.Env has already been initalized + m.Use(func(c *C, h http.Handler) http.Handler { + return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { + c.Env = make(map[string]interface{}) + h.ServeHTTP(w, r) + }) + }) + for path, eMethods := range validMethodsTable { + r, _ := http.NewRequest("BOGUS", path, nil) + m.ServeHTTP(httptest.NewRecorder(), r) + aMethods := <-ch + if !reflect.DeepEqual(eMethods, aMethods) { + t.Errorf("For %q, expected %v, got %v", path, eMethods, + aMethods) + } + } }