diff --git a/context_test.go b/context_test.go index 84ef8b4..e08c444 100644 --- a/context_test.go +++ b/context_test.go @@ -77,6 +77,25 @@ func TestContextReset(t *testing.T) { assert.Equal(t, c.Writer.(*responseWriter), &c.writermem) } +func TestContextHandlers(t *testing.T) { + c, _, _ := createTestContext() + assert.Nil(t, c.handlers) + assert.Nil(t, c.handlers.Last()) + + c.handlers = HandlersChain{} + assert.NotNil(t, c.handlers) + assert.Nil(t, c.handlers.Last()) + + f := func(c *Context) {} + g := func(c *Context) {} + + c.handlers = HandlersChain{f} + compareFunc(t, f, c.handlers.Last()) + + c.handlers = HandlersChain{f, g} + compareFunc(t, g, c.handlers.Last()) +} + // TestContextSetGet tests that a parameter is set correctly on the // current context and can be retrieved using Get. func TestContextSetGet(t *testing.T) { @@ -190,13 +209,13 @@ func TestContextQueryAndPostForm(t *testing.T) { var obj struct { Foo string `form:"foo"` - Id string `form:"id"` + ID string `form:"id"` Page string `form:"page"` Both string `form:"both"` } assert.NoError(t, c.Bind(&obj)) assert.Equal(t, obj.Foo, "bar") - assert.Equal(t, obj.Id, "main") + assert.Equal(t, obj.ID, "main") assert.Equal(t, obj.Page, "11") assert.Equal(t, obj.Both, "POST") } diff --git a/errors_test.go b/errors_test.go index 748e3fe..c9a3407 100644 --- a/errors_test.go +++ b/errors_test.go @@ -63,6 +63,7 @@ func TestErrorSlice(t *testing.T) { {Err: errors.New("third"), Type: ErrorTypePublic, Meta: H{"status": "400"}}, } + assert.Equal(t, errs, errs.ByType(ErrorTypeAny)) assert.Equal(t, errs.Last().Error(), "third") assert.Equal(t, errs.Errors(), []string{"first", "second", "third"}) assert.Equal(t, errs.ByType(ErrorTypePublic).Errors(), []string{"third"}) diff --git a/fs.go b/fs.go index f95dc84..6af3ded 100644 --- a/fs.go +++ b/fs.go @@ -14,7 +14,7 @@ type ( } ) -// It returns a http.Filesystem that can be used by http.FileServer(). It is used interally +// Dir returns a http.Filesystem that can be used by http.FileServer(). It is used interally // in router.Static(). // if listDirectory == true, then it works the same as http.Dir() otherwise it returns // a filesystem that prevents http.FileServer() to list the directory files. @@ -22,9 +22,8 @@ func Dir(root string, listDirectory bool) http.FileSystem { fs := http.Dir(root) if listDirectory { return fs - } else { - return &onlyfilesFS{fs} } + return &onlyfilesFS{fs} } // Conforms to http.Filesystem