shiori/internal/http/routes/frontend_test.go
Felipe Martin cc7c75116d
refactor: migrate bookmark static pages to new http server (#775)
* migrate bookmark content route to new http server

* new archive page

* remove unused go generate comment

* database mock

* utils cleanup

* unused var

* domains refactor and tests

* fixed secret key type

* redirect to login on ui errors

* fixed archive folder with storage domain

* webroot documentation

* some bookmark route tests

* fixed error in bookmark domain for non existant bookmarks

* centralice errors

* add coverage data to unittests

* added tests, refactor storage to use afero

* removed mock to avoid increasing complexity

* using deps to copy files around

* remove config usage (to deps)

* remove handler-ui file
2023-12-28 18:18:32 +01:00

47 lines
1.1 KiB
Go

package routes
import (
"context"
"net/http"
"net/http/httptest"
"testing"
"github.com/gin-gonic/gin"
"github.com/go-shiori/shiori/internal/http/templates"
"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()
templates.SetupTemplates(g)
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/style.css", func(t *testing.T) {
w := httptest.NewRecorder()
req, _ := http.NewRequest("GET", "/assets/css/style.css", nil)
g.ServeHTTP(w, req)
require.Equal(t, 200, w.Code)
})
}