refactor: [shitty claude AI first try] restructure server and user services, add new test cases, and improve error handling

This commit is contained in:
2025-08-10 21:40:15 +03:00
parent 588576b82f
commit f503e45be1
23 changed files with 2568 additions and 134 deletions

View File

@ -0,0 +1,48 @@
package server
import (
"net/http/httptest"
"testing"
"git.logidex.ru/fakz9/logidex-id/internal/config"
"github.com/gofiber/fiber/v2"
"github.com/stretchr/testify/assert"
)
func TestNewFiberApp(t *testing.T) {
cfg := config.Config{}
cfg.App.Port = 8080
app := NewFiberApp(cfg)
assert.NotNil(t, app)
// Test health check endpoint
req := httptest.NewRequest("GET", "/health", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
}
func TestNewAPIRouter(t *testing.T) {
cfg := config.Config{}
cfg.App.Port = 8080
app := NewFiberApp(cfg)
router := NewAPIRouter(app)
assert.NotNil(t, router)
// Test that we can add routes to the router
router.Get("/test", func(c *fiber.Ctx) error {
return c.JSON(map[string]string{"message": "test"})
})
// Test the route works
req := httptest.NewRequest("GET", "/api/test", nil)
resp, err := app.Test(req)
assert.NoError(t, err)
assert.Equal(t, 200, resp.StatusCode)
}