first commit
This commit is contained in:
62
routers/router_test.go
Normal file
62
routers/router_test.go
Normal file
@@ -0,0 +1,62 @@
|
||||
package routers
|
||||
|
||||
import (
|
||||
"net/http"
|
||||
"net/http/httptest"
|
||||
"testing"
|
||||
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
func TestSetupRegistersCoreRoutes(t *testing.T) {
|
||||
gin.SetMode(gin.TestMode)
|
||||
|
||||
r := gin.New()
|
||||
Setup(r)
|
||||
|
||||
cases := []struct {
|
||||
method string
|
||||
path string
|
||||
}{
|
||||
{method: http.MethodGet, path: "/swagger/index.html"},
|
||||
{method: http.MethodPost, path: "/api/v1/auth/register"},
|
||||
{method: http.MethodPost, path: "/api/v1/auth/login"},
|
||||
{method: http.MethodPost, path: "/api/v1/auth/refresh"},
|
||||
{method: http.MethodGet, path: "/api/v1/auth/verify-email"},
|
||||
{method: http.MethodPost, path: "/api/v1/auth/social/google"},
|
||||
{method: http.MethodPost, path: "/api/v1/auth/social/github"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs/categories"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs/categories/genel"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs/tags"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs/tags/go"},
|
||||
{method: http.MethodGet, path: "/api/v1/blogs/test-slug"},
|
||||
{method: http.MethodGet, path: "/api/v1/me"},
|
||||
{method: http.MethodGet, path: "/api/v1/me/profile"},
|
||||
{method: http.MethodPut, path: "/api/v1/me/profile"},
|
||||
{method: http.MethodPost, path: "/api/v1/images/process"},
|
||||
{method: http.MethodGet, path: "/api/v1/images"},
|
||||
{method: http.MethodGet, path: "/api/v1/images/1"},
|
||||
{method: http.MethodPost, path: "/api/v1/blogs"},
|
||||
{method: http.MethodPut, path: "/api/v1/blogs/1"},
|
||||
{method: http.MethodDelete, path: "/api/v1/blogs/1"},
|
||||
{method: http.MethodPost, path: "/api/v1/blogs/categories"},
|
||||
{method: http.MethodPut, path: "/api/v1/blogs/categories/1"},
|
||||
{method: http.MethodDelete, path: "/api/v1/blogs/categories/1"},
|
||||
{method: http.MethodPost, path: "/api/v1/blogs/tags"},
|
||||
{method: http.MethodPut, path: "/api/v1/blogs/tags/1"},
|
||||
{method: http.MethodDelete, path: "/api/v1/blogs/tags/1"},
|
||||
{method: http.MethodGet, path: "/api/v1/admin/users/1/profile"},
|
||||
{method: http.MethodPut, path: "/api/v1/admin/users/1/profile"},
|
||||
}
|
||||
|
||||
for _, tc := range cases {
|
||||
req := httptest.NewRequest(tc.method, tc.path, nil)
|
||||
w := httptest.NewRecorder()
|
||||
r.ServeHTTP(w, req)
|
||||
|
||||
if w.Code == http.StatusNotFound {
|
||||
t.Fatalf("expected route %s %s to be registered", tc.method, tc.path)
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user