File tree Expand file tree Collapse file tree 2 files changed +16
-1
lines changed
Expand file tree Collapse file tree 2 files changed +16
-1
lines changed Original file line number Diff line number Diff line change @@ -109,7 +109,7 @@ func (g *Group) Static(prefix, root string) {
109109
110110// File implements `Echo#File()` for sub-routes within the Group.
111111func (g * Group ) File (path , file string ) {
112- g .file (g . prefix + path , file , g .GET )
112+ g .file (path , file , g .GET )
113113}
114114
115115// Add implements `Echo#Add()` for sub-routes within the Group.
Original file line number Diff line number Diff line change 11package echo
22
33import (
4+ "io/ioutil"
45"net/http"
6+ "net/http/httptest"
57"testing"
68
79"github.com/stretchr/testify/assert"
@@ -26,6 +28,19 @@ func TestGroup(t *testing.T) {
2628g .File ("/walle" , "_fixture/images//walle.png" )
2729}
2830
31+ func TestGroupFile (t * testing.T ) {
32+ e := New ()
33+ g := e .Group ("/group" )
34+ g .File ("/walle" , "_fixture/images/walle.png" )
35+ expectedData , err := ioutil .ReadFile ("_fixture/images/walle.png" )
36+ assert .Nil (t , err )
37+ req := httptest .NewRequest (http .MethodGet , "/group/walle" , nil )
38+ rec := httptest .NewRecorder ()
39+ e .ServeHTTP (rec , req )
40+ assert .Equal (t , http .StatusOK , rec .Code )
41+ assert .Equal (t , expectedData , rec .Body .Bytes ())
42+ }
43+
2944func TestGroupRouteMiddleware (t * testing.T ) {
3045// Ensure middleware slices are not re-used
3146e := New ()
You can’t perform that action at this time.
0 commit comments