shiori/internal/http/routes/frontend_test.go
Felipe Martin a60dbf3dc5
Run legacy API and new API at the same time. (#648)
* config: backwards comptabile dir

* remove duplicated frontend

* frontend: move assets to assets folder

* legacy routes handler in gin

* templates and asset in different embed

* new routes

* frontend routes serve old views

* added DTO for account object

* api auth calls legacy handler

* frontend: handle new error messages

* frontend: update urls

* frontend: login using new api

* updated frontend tests

* chore: remove debug route

* create shiori/gopher user if no owner is present

* server as default command

* serve -> server

* refactored database logic, allow database url

* removed unused configuration

* storage docs

* refactor cli to use cfg and deps

* check errors only in server

* log fatal instead of os exit

* dont default data directory to current dir

* fixed sqlite path

* trigger build on prs

* avoid releasing if lint/test fails

* pull request condition

* event -> event_name

* Get correct pull request number

* added workflow to delete dangling tags

* fix: nil error checking

* set gin mode first

* set gin mode before initialization

* fix logger

* allow version bump from custom ref

* Updated matrix link to workspace
2023-07-19 18:25:41 +02:00

44 lines
1,020 B
Go

package routes
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/go-shiori/shiori/internal/testutil"
"github.com/sirupsen/logrus"
"github.com/stretchr/testify/require"
)
func TestFrontendRoutes(t *testing.T) {
logger := logrus.New()
cfg, _ := testutil.GetTestConfigurationAndDependencies(t, context.Background(), logger)
g := gin.Default()
router := NewFrontendRoutes(logger, cfg)
router.Setup(g)
t.Run("/", func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/", nil)
g.ServeHTTP(w, req)
require.Equal(t, 200, w.Code)
})
t.Run("/login", func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/login", nil)
g.ServeHTTP(w, req)
require.Equal(t, 200, w.Code)
})
t.Run("/css/stylesheet.css", func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/assets/css/stylesheet.css", nil)
g.ServeHTTP(w, req)
require.Equal(t, 200, w.Code)
})
}