mirror of
https://github.com/go-shiori/shiori.git
synced 2025-09-13 00:16:34 +08:00
* 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
44 lines
1,020 B
Go
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)
|
|
})
|
|
}
|