35 lines
703 B
Go
35 lines
703 B
Go
package server
|
|
|
|
import (
|
|
"net/http"
|
|
"net/http/httptest"
|
|
"testing"
|
|
|
|
"billit/internal/database"
|
|
|
|
"github.com/labstack/echo/v4"
|
|
)
|
|
|
|
func TestHomeRoute(t *testing.T) {
|
|
// Create a minimal server with db for testing
|
|
db := database.New()
|
|
s := &Server{db: db}
|
|
handler := s.RegisterRoutes()
|
|
|
|
req := httptest.NewRequest(http.MethodGet, "/", nil)
|
|
resp := httptest.NewRecorder()
|
|
handler.ServeHTTP(resp, req)
|
|
|
|
if resp.Code != http.StatusOK {
|
|
t.Errorf("home route wrong status code = %v, want %v", resp.Code, http.StatusOK)
|
|
}
|
|
}
|
|
|
|
func TestRouterSetup(t *testing.T) {
|
|
// Test that Echo router can be set up without panic
|
|
e := echo.New()
|
|
if e == nil {
|
|
t.Error("failed to create echo instance")
|
|
}
|
|
}
|