Files
narco/narco_test.go

37 lines
823 B
Go

package narco
import (
"net/http"
"net/http/httptest"
"testing"
"github.com/codemodus/chain"
"golang.org/x/net/context"
. "gopkg.in/check.v1"
)
type NarcoSuite struct {
chain chain.Chain
ctx context.Context
}
func Test(t *testing.T) { TestingT(t) }
func NewNarcoSuite() *NarcoSuite {
ctx := context.Background()
return &NarcoSuite{
ctx: ctx,
chain: chain.New(),
}
}
func (s *NarcoSuite) ServeHTTP(rec *httptest.ResponseRecorder, req *http.Request, handlerfunc http.HandlerFunc) {
s.chain.EndFn(func(ctx context.Context, rw http.ResponseWriter, req *http.Request) {
handlerfunc.ServeHTTP(rw, req)
}).ServeHTTP(rec, req)
}
func (s *NarcoSuite) ServeHTTPContext(rec *httptest.ResponseRecorder, req *http.Request, handlerfunc chain.HandlerFunc) {
s.chain.EndFn(handlerfunc).ServeHTTP(rec, req)
}