Skip to content
This repository was archived by the owner on Mar 4, 2020. It is now read-only.

Commit 5e0c0cc

Browse files
authored
Add test for httprouter handle.
1 parent f7c46a0 commit 5e0c0cc

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

router_test.go

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -192,3 +192,20 @@ func TestHandleFunc4(t *testing.T) {
192192
t.Error("routing GET failed")
193193
}
194194
}
195+
196+
func TestHandleFunc5(t *testing.T) {
197+
var get bool
198+
199+
router := NewRouter()
200+
router.Get("/GET", func(w http.ResponseWriter, r *http.Request, _ Params) {
201+
get = true
202+
})
203+
204+
w := new(mockResponseWriter)
205+
206+
r, _ := http.NewRequest("GET", "/GET", nil)
207+
router.ServeHTTP(w, r)
208+
if !get {
209+
t.Error("routing GET failed")
210+
}
211+
}

0 commit comments

Comments
 (0)