Server : LiteSpeed System : Linux in-mum-web1112.main-hosting.eu 4.18.0-553.34.1.lve.el8.x86_64 #1 SMP Thu Jan 9 16:30:32 UTC 2025 x86_64 User : u451330669 ( 451330669) PHP Version : 8.2.27 Disable Function : NONE Directory : /opt/go/pkg/mod/github.com/go-openapi/runtime@v0.26.0/middleware/ |
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)
}