1
0
mirror of https://github.com/labstack/echo.git synced 2025-04-27 12:32:09 +02:00

Coverage for printTree

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-03-31 08:26:00 -07:00
parent 0acb268603
commit 3868503d51

View File

@ -4,8 +4,8 @@ import "testing"
func TestRouterStatic(t *testing.T) { func TestRouterStatic(t *testing.T) {
r := New().Router r := New().Router
r.Add("GET", "/users/joe/books", func(c *Context) {}) r.Add("GET", "/folders/files/bolt.gif", func(c *Context) {})
h, _, _ := r.Find("GET", "/users/joe/books") h, _, _ := r.Find("GET", "/folders/files/bolt.gif")
if h == nil { if h == nil {
t.Fatal("handle not found") t.Fatal("handle not found")
} }
@ -13,14 +13,14 @@ func TestRouterStatic(t *testing.T) {
func TestRouterParam(t *testing.T) { func TestRouterParam(t *testing.T) {
r := New().Router r := New().Router
r.Add("GET", "/users/:name", func(c *Context) {}) r.Add("GET", "/users/:id", func(c *Context) {})
h, c, _ := r.Find("GET", "/users/joe") h, c, _ := r.Find("GET", "/users/1")
if h == nil { if h == nil {
t.Fatal("handle not found") t.Fatal("handle not found")
} }
p := c.Param("name") p := c.Param("id")
if p != "joe" { if p != "1" {
t.Errorf("name should be equal to joe, found %s", p) t.Errorf("id should be equal to 1, found %s", p)
} }
} }
@ -53,3 +53,13 @@ func TestRouterMicroParam(t *testing.T) {
t.Errorf("p3 should be equal to c, found %s", p3) t.Errorf("p3 should be equal to c, found %s", p3)
} }
} }
func TestPrintTree(t *testing.T) {
r := New().Router
r.Add("GET", "/users", nil)
r.Add("GET", "/users/:id", nil)
r.Add("GET", "/users/:id/books", nil)
r.Add("GET", "/users/:id/files", nil)
r.Add("POST", "/files", nil)
r.printTree()
}