2018-09-05 14:06:30 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
|
|
|
"io/ioutil"
|
|
|
|
"net/http"
|
|
|
|
"net/http/httptest"
|
|
|
|
"testing"
|
|
|
|
|
|
|
|
"github.com/labstack/echo"
|
2018-09-07 04:34:02 +02:00
|
|
|
"github.com/pangpanglabs/echoswagger"
|
2018-09-05 14:06:30 +02:00
|
|
|
"github.com/stretchr/testify/assert"
|
|
|
|
)
|
|
|
|
|
|
|
|
func TestMain(t *testing.T) {
|
|
|
|
e := initServer()
|
|
|
|
req := httptest.NewRequest(echo.GET, "/doc/swagger.json", nil)
|
|
|
|
rec := httptest.NewRecorder()
|
|
|
|
c := e.Echo().NewContext(req, rec)
|
|
|
|
b, err := ioutil.ReadFile("./swagger.json")
|
|
|
|
assert.Nil(t, err)
|
|
|
|
if assert.NoError(t, e.(*echoswagger.Root).Spec(c)) {
|
|
|
|
assert.Equal(t, http.StatusOK, rec.Code)
|
|
|
|
assert.JSONEq(t, string(b), rec.Body.String())
|
|
|
|
}
|
|
|
|
}
|