mirror of
https://github.com/fnproject/fn.git
synced 2022-10-28 21:29:17 +03:00
23 lines
655 B
Go
23 lines
655 B
Go
package middleware
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"github.com/stretchr/testify/assert"
|
|
)
|
|
|
|
func TestRedocMiddleware(t *testing.T) {
|
|
redoc := Redoc(RedocOpts{}, nil)
|
|
|
|
req, _ := http.NewRequest("GET", "/docs", nil)
|
|
recorder := httptest.NewRecorder()
|
|
redoc.ServeHTTP(recorder, req)
|
|
assert.Equal(t, 200, recorder.Code)
|
|
assert.Equal(t, "text/html; charset=utf-8", recorder.Header().Get("Content-Type"))
|
|
assert.Contains(t, recorder.Body.String(), "<title>API documentation</title>")
|
|
assert.Contains(t, recorder.Body.String(), "<redoc spec-url='/swagger.json'></redoc>")
|
|
assert.Contains(t, recorder.Body.String(), redocLatest)
|
|
}
|