mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
Finally rid of capital Sirupsen??
This commit is contained in:
26
vendor/github.com/go-openapi/runtime/middleware/validation_test.go
generated
vendored
26
vendor/github.com/go-openapi/runtime/middleware/validation_test.go
generated
vendored
@@ -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`)))
|
||||
|
||||
Reference in New Issue
Block a user