File tree Expand file tree Collapse file tree 4 files changed +4
-11
lines changed Expand file tree Collapse file tree 4 files changed +4
-11
lines changed Original file line number Diff line number Diff line change @@ -332,7 +332,6 @@ func TestBindbindData(t *testing.T) {
332332
333333func TestBindParam (t * testing.T ) {
334334 e := New ()
335- * e .maxParam = 2
336335 req := httptest .NewRequest (GET , "/" , nil )
337336 rec := httptest .NewRecorder ()
338337 c := e .NewContext (req , rec )
@@ -363,7 +362,6 @@ func TestBindParam(t *testing.T) {
363362 // Bind something with param and post data payload
364363 body := bytes .NewBufferString (`{ "name": "Jon Snow" }` )
365364 e2 := New ()
366- * e2 .maxParam = 2
367365 req2 := httptest .NewRequest (POST , "/" , body )
368366 req2 .Header .Set (HeaderContentType , MIMEApplicationJSON )
369367
Original file line number Diff line number Diff line change @@ -310,17 +310,15 @@ func (c *context) ParamNames() []string {
310310
311311func (c * context ) SetParamNames (names ... string ) {
312312 c .pnames = names
313+ * c .echo .maxParam = len (names )
313314}
314315
315316func (c * context ) ParamValues () []string {
316317 return c .pvalues [:len (c .pnames )]
317318}
318319
319320func (c * context ) SetParamValues (values ... string ) {
320- // NOTE: Don't just set c.pvalues = values, because it has to have length c.echo.maxParam at all times
321- for i , val := range values {
322- c .pvalues [i ] = val
323- }
321+ c .pvalues = values
324322}
325323
326324func (c * context ) QueryParam (name string ) string {
Original file line number Diff line number Diff line change @@ -93,7 +93,6 @@ func (responseWriterErr) WriteHeader(statusCode int) {
9393
9494func TestContext (t * testing.T ) {
9595 e := New ()
96- * e .maxParam = 1
9796 req := httptest .NewRequest (http .MethodPost , "/" , strings .NewReader (userJSON ))
9897 rec := httptest .NewRecorder ()
9998 c := e .NewContext (req , rec ).(* context )
@@ -472,7 +471,6 @@ func TestContextPath(t *testing.T) {
472471
473472func TestContextPathParam (t * testing.T ) {
474473 e := New ()
475- * e .maxParam = 2
476474 req := httptest .NewRequest (http .MethodGet , "/" , nil )
477475 c := e .NewContext (req , nil )
478476
@@ -491,7 +489,8 @@ func TestContextPathParam(t *testing.T) {
491489
492490func TestContextGetAndSetParam (t * testing.T ) {
493491 e := New ()
494- * e .maxParam = 2
492+ r := e .Router ()
493+ r .Add (http .MethodGet , "/:foo" , func (Context ) error { return nil })
495494 req := httptest .NewRequest (http .MethodGet , "/:foo" , nil )
496495 c := e .NewContext (req , nil )
497496 c .SetParamNames ("foo" )
Original file line number Diff line number Diff line change @@ -60,8 +60,6 @@ func TestJWTRace(t *testing.T) {
6060
6161func TestJWT (t * testing.T ) {
6262 e := echo .New ()
63- r := e .Router ()
64- r .Add ("GET" , "/:jwt" , func (echo.Context ) error { return nil })
6563 handler := func (c echo.Context ) error {
6664 return c .String (http .StatusOK , "test" )
6765 }
You can’t perform that action at this time.
0 commit comments