Compare commits
2 Commits
7518896cfe
...
413cf51f74
| Author | SHA1 | Date | |
|---|---|---|---|
| 413cf51f74 | |||
| 6426419b8b |
@@ -256,7 +256,7 @@ Goyco includes a comprehensive CLI for administration:
|
||||
### Get the sources
|
||||
|
||||
```bash
|
||||
git clone https://github.com/sandrocazzaniga/goyco.git
|
||||
git clone https://git.kharec.info/Kharec/goyco.git
|
||||
cd goyco
|
||||
```
|
||||
|
||||
|
||||
@@ -13,6 +13,8 @@ import (
|
||||
"goyco/internal/repositories"
|
||||
"goyco/internal/services"
|
||||
"goyco/internal/testutils"
|
||||
|
||||
"github.com/go-chi/chi/v5"
|
||||
)
|
||||
|
||||
func TestAPIHandlerGetAPIInfo(t *testing.T) {
|
||||
@@ -278,3 +280,49 @@ func TestNewAPIHandlerWithMonitoring_NilDB(t *testing.T) {
|
||||
t.Error("Expected metricsCollector to be nil when db is nil")
|
||||
}
|
||||
}
|
||||
|
||||
func TestAPIHandlerMountRoutes(t *testing.T) {
|
||||
mockPostRepo := testutils.NewPostRepositoryStub()
|
||||
mockUserRepo := testutils.NewUserRepositoryStub()
|
||||
handler := newAPIHandlerForTest(mockPostRepo, mockUserRepo)
|
||||
|
||||
router := chi.NewRouter()
|
||||
config := RouteModuleConfig{}
|
||||
|
||||
router.Route("/api", func(r chi.Router) {
|
||||
handler.MountRoutes(r, config)
|
||||
})
|
||||
|
||||
t.Run("GET route works", func(t *testing.T) {
|
||||
request := httptest.NewRequest(http.MethodGet, "/api", nil)
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
router.ServeHTTP(recorder, request)
|
||||
|
||||
testutils.AssertHTTPStatus(t, recorder, http.StatusOK)
|
||||
|
||||
var resp APIInfo
|
||||
if err := json.NewDecoder(recorder.Body).Decode(&resp); err != nil {
|
||||
t.Fatalf("failed to decode response: %v", err)
|
||||
}
|
||||
|
||||
if !resp.Success {
|
||||
t.Fatalf("expected success response, got %+v", resp)
|
||||
}
|
||||
})
|
||||
|
||||
t.Run("only GET is mounted", func(t *testing.T) {
|
||||
methods := []string{http.MethodPost, http.MethodPut, http.MethodDelete}
|
||||
|
||||
for _, method := range methods {
|
||||
request := httptest.NewRequest(method, "/api", nil)
|
||||
recorder := httptest.NewRecorder()
|
||||
|
||||
router.ServeHTTP(recorder, request)
|
||||
|
||||
if recorder.Code != http.StatusMethodNotAllowed && recorder.Code != http.StatusNotFound {
|
||||
t.Errorf("expected method not allowed or not found for %s, got %d", method, recorder.Code)
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
@@ -54,7 +54,7 @@
|
||||
|
||||
<footer class="site-footer">
|
||||
<div class="container">
|
||||
<small>Powered with ❤️ by <a href="https://github.com/sandrocazzaniga/goyco">Goyco</a></small>
|
||||
<small>Powered with ❤️ by <a href="https://git.kharec.info/Kharec/goyco">Goyco</a></small>
|
||||
</div>
|
||||
</footer>
|
||||
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
[Unit]
|
||||
Description=Goyco - Self-hosted news aggregation platform
|
||||
Documentation=https://github.com/sandrocazzaniga/goyco
|
||||
Documentation=https://git.kharec.info/Kharec/goyco
|
||||
After=network-online.target postgresql.service
|
||||
|
||||
[Service]
|
||||
|
||||
Reference in New Issue
Block a user