/* * Copyright (c) 2019 Alex aka mailoman * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * * @author Alex aka mailoman * @copyright Copyright (c) 2019 Alex aka mailoman * @since 18.12.2019 * */ package main import ( "encoding/json" "io/ioutil" "net/http/httptest" "testing" "github.com/labstack/echo/v4" "github.com/stretchr/testify/assert" "git.webz.asia/echo-go/echoswagger" ) 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) 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)) }