datarhei-dragonfork-core/http/handler/api/about_test.go

37 lines
682 B
Go
Raw Normal View History

2022-05-13 13:26:45 -04:00
package api
import (
"net/http"
"testing"
"github.com/datarhei/core/v16/http/api"
"github.com/datarhei/core/v16/http/mock"
"github.com/stretchr/testify/require"
2022-05-13 13:26:45 -04:00
"github.com/labstack/echo/v4"
)
func getDummyAboutRouter() (*echo.Echo, error) {
2022-05-13 13:26:45 -04:00
router := mock.DummyEcho()
rs, err := mock.DummyRestreamer("../../mock")
if err != nil {
return nil, err
}
2022-05-13 13:26:45 -04:00
handler := NewAbout(rs, []string{})
router.Add("GET", "/", handler.About)
return router, nil
2022-05-13 13:26:45 -04:00
}
func TestAbout(t *testing.T) {
router, err := getDummyAboutRouter()
require.NoError(t, err)
2022-05-13 13:26:45 -04:00
response := mock.Request(t, http.StatusOK, router, "GET", "/", nil)
mock.Validate(t, &api.About{}, response.Data)
}