Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Tree: 75d1bb4676
Fetching contributors…

Cannot retrieve contributors at this time

31 lines (24 sloc) 0.607 kB
package falcore
import (
"net/http"
"testing"
"fmt"
"io/ioutil"
)
func TestHandlerFilter(t *testing.T) {
reply := "Hello, World"
handler := func(w http.ResponseWriter, r *http.Request) {
fmt.Fprintf(w, reply)
}
hff := NewHandlerFilter(http.HandlerFunc(handler))
tmp, _ := http.NewRequest("GET", "/hello", nil)
_, res := TestWithRequest(tmp, hff)
if res == nil {
t.Errorf("Response is nil")
}
if replyGot, err := ioutil.ReadAll(res.Body); err != nil {
t.Errorf("Error reading body: %v", err)
} else if string(replyGot) != reply {
t.Errorf("Expected body does not match")
}
}
Jump to Line
Something went wrong with that request. Please try again.