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) {
109
109
110
110
// File implements `Echo#File()` for sub-routes within the Group.
111
111
func (g * Group ) File (path , file string ) {
112
- g .file (g . prefix + path , file , g .GET )
112
+ g .file (path , file , g .GET )
113
113
}
114
114
115
115
// Add implements `Echo#Add()` for sub-routes within the Group.
Original file line number Diff line number Diff line change 1
1
package echo
2
2
3
3
import (
4
+ "io/ioutil"
4
5
"net/http"
6
+ "net/http/httptest"
5
7
"testing"
6
8
7
9
"github.com/stretchr/testify/assert"
@@ -26,6 +28,19 @@ func TestGroup(t *testing.T) {
26
28
g .File ("/walle" , "_fixture/images//walle.png" )
27
29
}
28
30
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
+
29
44
func TestGroupRouteMiddleware (t * testing.T ) {
30
45
// Ensure middleware slices are not re-used
31
46
e := New ()
You can’t perform that action at this time.
0 commit comments