feat: rebuild pet app and backend around core care flows

This commit is contained in:
2026-10-01 13:11:30 +08:00
parent 51ead8f411
commit bfcf8788a4
321 changed files with 4918 additions and 25199 deletions
@@ -0,0 +1,38 @@
package httpapi
import (
"net/http"
"net/http/httptest"
"strings"
"testing"
"github.com/gin-gonic/gin"
"github.com/sundynix/pets-be/internal/config"
)
func TestLoginRoute(t *testing.T) {
gin.SetMode(gin.TestMode)
router := gin.New()
New(nil, nil, &config.Config{}).Register(router)
for _, route := range router.Routes() {
if !strings.HasPrefix(route.Path, "/api/") {
t.Errorf("API route %q does not have /api/ prefix", route.Path)
}
}
for _, test := range []struct {
path string
want int
}{
{path: "/api/auth/login", want: http.StatusBadRequest},
{path: "/api/auth/wechat", want: http.StatusNotFound},
} {
recorder := httptest.NewRecorder()
request := httptest.NewRequest(http.MethodPost, test.path, strings.NewReader(`{}`))
request.Header.Set("Content-Type", "application/json")
router.ServeHTTP(recorder, request)
if recorder.Code != test.want {
t.Errorf("POST %s: got %d, want %d", test.path, recorder.Code, test.want)
}
}
}