feat: rebuild pet app and backend around core care flows
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user