diff --git a/static_test.go b/static_test.go index 243a558..b92526d 100644 --- a/static_test.go +++ b/static_test.go @@ -1,6 +1,7 @@ package martini import ( + "bytes" "net/http" "net/http/httptest" "testing" @@ -8,26 +9,34 @@ import ( func Test_Static(t *testing.T) { response := httptest.NewRecorder() + response.Body = new(bytes.Buffer) m := New() + r := NewRouter() m.Use(Static(".")) + m.Action(r.Handle) req, err := http.NewRequest("GET", "http://localhost:3000/martini.go", nil) if err != nil { t.Error(err) } - m.ServeHTTP(response, req) expect(t, response.Code, http.StatusOK) + if response.Body.Len() == 0 { + t.Errorf("Got empty body for GET request") + } } func Test_Static_Head(t *testing.T) { response := httptest.NewRecorder() + response.Body = new(bytes.Buffer) m := New() + r := NewRouter() m.Use(Static(".")) + m.Action(r.Handle) req, err := http.NewRequest("HEAD", "http://localhost:3000/martini.go", nil) if err != nil { @@ -36,6 +45,9 @@ func Test_Static_Head(t *testing.T) { m.ServeHTTP(response, req) expect(t, response.Code, http.StatusOK) + if response.Body.Len() != 0 { + t.Errorf("Got non-empty body for HEAD request") + } } func Test_Static_As_Post(t *testing.T) {