2018-09-05 14:06:30 +02:00
|
|
|
package main
|
|
|
|
|
|
|
|
import (
|
2019-05-12 17:10:04 +02:00
|
|
|
"encoding/json"
|
2018-09-05 14:06:30 +02:00
|
|
|
"io/ioutil"
|
|
|
|
"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)
|
2019-05-12 17:10:04 +02:00
|
|
|
s, err := e.(*echoswagger.Root).GetSpec(c, "/doc")
|
|
|
|
assert.Nil(t, err)
|
|
|
|
rs, err := json.Marshal(s)
|
|
|
|
assert.Nil(t, err)
|
|
|
|
assert.JSONEq(t, string(b), string(rs))
|
2018-09-05 14:06:30 +02:00
|
|
|
}
|