github.com/lenfree/buffalo@v0.7.3-0.20170207163156-891616ea4064/route_test.go (about) 1 package buffalo 2 3 import ( 4 "testing" 5 6 "github.com/stretchr/testify/require" 7 ) 8 9 func Test_App_Routes_without_Root(t *testing.T) { 10 r := require.New(t) 11 12 a := New(Options{}) 13 r.Nil(a.root) 14 15 a.GET("/foo", voidHandler) 16 17 routes := a.Routes() 18 r.Len(routes, 1) 19 route := routes[0] 20 r.Equal("GET", route.Method) 21 r.Equal("/foo", route.Path) 22 r.NotZero(route.HandlerName) 23 } 24 25 func Test_App_Routes_with_Root(t *testing.T) { 26 r := require.New(t) 27 28 a := New(Options{}) 29 r.Nil(a.root) 30 31 g := a.Group("/api/v1") 32 g.GET("/foo", voidHandler) 33 34 routes := a.Routes() 35 r.Len(routes, 1) 36 route := routes[0] 37 r.Equal("GET", route.Method) 38 r.Equal("/api/v1/foo", route.Path) 39 r.NotZero(route.HandlerName) 40 41 r.Equal(a.Routes(), g.Routes()) 42 }