forked from swaggo/echo-swagger
-
Notifications
You must be signed in to change notification settings - Fork 0
/
swagger_test.go
41 lines (29 loc) · 940 Bytes
/
swagger_test.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
package echoswagger
import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
"github.com/webx-top/echo"
_ "github.com/webx-top/echo-swagger/example/docs"
mw "github.com/webx-top/echo/middleware"
otesting "github.com/webx-top/echo/testing"
)
func TestWrapHandler(t *testing.T) {
router := echo.New()
router.RouteDebug = true
router.SetDebug(true)
router.Use(mw.Recover(), mw.Log())
router.Get("/*", WrapHandler)
router.Commit()
w1 := performRequest("GET", "/index.html", router)
assert.Equal(t, 200, w1.Code)
w2 := performRequest("GET", "/doc.json", router)
assert.Equal(t, 200, w2.Code)
w3 := performRequest("GET", "/favicon-16x16.png", router)
assert.Equal(t, 200, w3.Code)
w4 := performRequest("GET", "/notfound", router)
assert.Equal(t, 404, w4.Code)
}
func performRequest(method, target string, e *echo.Echo) *httptest.ResponseRecorder {
return otesting.Request(method, target, e)
}