Files
rest-server/vendor/goji.io/dispatch_test.go
Alexander Neumann 6054876201 Vendor dependencies
2016-12-30 18:34:37 +01:00

33 lines
559 B
Go

package goji
import (
"context"
"net/http"
"testing"
"goji.io/internal"
)
func TestDispatch(t *testing.T) {
t.Parallel()
var d dispatch
w, r := wr()
d.ServeHTTP(w, r)
if w.Code != 404 {
t.Errorf("status: expected %d, got %d", 404, w.Code)
}
w, r = wr()
h := http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(123)
})
ctx := context.WithValue(context.Background(), internal.Handler, h)
r = r.WithContext(ctx)
d.ServeHTTP(w, r)
if w.Code != 123 {
t.Errorf("status: expected %d, got %d", 123, w.Code)
}
}