mirror of
https://github.com/documize/community.git
synced 2025-07-22 14:49:42 +02:00
initial commit
This commit is contained in:
commit
18933c6767
1841 changed files with 810642 additions and 0 deletions
28
vendor/github.com/codegangsta/negroni/recovery_test.go
generated
vendored
Normal file
28
vendor/github.com/codegangsta/negroni/recovery_test.go
generated
vendored
Normal file
|
@ -0,0 +1,28 @@
|
|||
package negroni
|
||||
|
||||
import (
|
||||
"bytes"
|
||||
"log"
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
)
|
||||
|
||||
func TestRecovery(t *testing.T) {
|
||||
buff := bytes.NewBufferString("")
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
rec := NewRecovery()
|
||||
rec.Logger = log.New(buff, "[negroni] ", 0)
|
||||
|
||||
n := New()
|
||||
// replace log for testing
|
||||
n.Use(rec)
|
||||
n.UseHandler(http.HandlerFunc(func(res http.ResponseWriter, req *http.Request) {
|
||||
panic("here is a panic!")
|
||||
}))
|
||||
n.ServeHTTP(recorder, (*http.Request)(nil))
|
||||
expect(t, recorder.Code, http.StatusInternalServerError)
|
||||
refute(t, recorder.Body.Len(), 0)
|
||||
refute(t, len(buff.String()), 0)
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue