Finally rid of capital Sirupsen??

This commit is contained in:
Travis Reeder
2017-09-18 23:33:47 -07:00
parent f335d34636
commit 3aecebdf48
1127 changed files with 41199 additions and 41383 deletions

View File

@@ -26,33 +26,11 @@ import (
"github.com/stretchr/testify/assert"
)
func newTestValidation(ctx *Context, next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
matched, rCtx, _ := ctx.RouteInfo(r)
if rCtx != nil {
r = rCtx
}
if matched == nil {
ctx.NotFound(rw, r)
return
}
_, r, result := ctx.BindAndValidate(r, matched)
if result != nil {
ctx.Respond(rw, r, matched.Produces, matched, result)
return
}
next.ServeHTTP(rw, r)
})
}
func TestContentTypeValidation(t *testing.T) {
spec, api := petstore.NewAPI(t)
context := NewContext(spec, api, nil)
context.router = DefaultRouter(spec, context.api)
mw := newTestValidation(context, http.HandlerFunc(terminator))
mw := newValidation(context, http.HandlerFunc(terminator))
recorder := httptest.NewRecorder()
request, _ := http.NewRequest("GET", "/api/pets", nil)
@@ -104,7 +82,7 @@ func TestResponseFormatValidation(t *testing.T) {
spec, api := petstore.NewAPI(t)
context := NewContext(spec, api, nil)
context.router = DefaultRouter(spec, context.api)
mw := newTestValidation(context, http.HandlerFunc(terminator))
mw := newValidation(context, http.HandlerFunc(terminator))
recorder := httptest.NewRecorder()
request, _ := http.NewRequest("POST", "/api/pets", bytes.NewBuffer([]byte(`name: Dog`)))