少提交的东西
This commit is contained in:
@@ -20,7 +20,7 @@ import (
|
||||
"gorm.io/gorm/logger"
|
||||
|
||||
"github.com/break/junhong_cmp_fiber/internal/bootstrap"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler"
|
||||
"github.com/break/junhong_cmp_fiber/internal/handler/admin"
|
||||
"github.com/break/junhong_cmp_fiber/internal/model"
|
||||
"github.com/break/junhong_cmp_fiber/internal/routes"
|
||||
permissionService "github.com/break/junhong_cmp_fiber/internal/service/permission"
|
||||
@@ -81,7 +81,7 @@ func setupPermTestEnv(t *testing.T) *permTestEnv {
|
||||
permSvc := permissionService.New(permStore)
|
||||
|
||||
// 初始化 Handler
|
||||
permHandler := handler.NewPermissionHandler(permSvc)
|
||||
permHandler := admin.NewPermissionHandler(permSvc)
|
||||
|
||||
// 创建 Fiber App
|
||||
app := fiber.New(fiber.Config{
|
||||
@@ -130,7 +130,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
req := httptest.NewRequest("POST", "/api/v1/permissions", bytes.NewReader(jsonBody))
|
||||
req := httptest.NewRequest("POST", "/api/admin/permissions", bytes.NewReader(jsonBody))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := env.app.Test(req)
|
||||
@@ -166,7 +166,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
req := httptest.NewRequest("POST", "/api/v1/permissions", bytes.NewReader(jsonBody))
|
||||
req := httptest.NewRequest("POST", "/api/admin/permissions", bytes.NewReader(jsonBody))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := env.app.Test(req)
|
||||
@@ -197,7 +197,7 @@ func TestPermissionAPI_Create(t *testing.T) {
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
req := httptest.NewRequest("POST", "/api/v1/permissions", bytes.NewReader(jsonBody))
|
||||
req := httptest.NewRequest("POST", "/api/admin/permissions", bytes.NewReader(jsonBody))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := env.app.Test(req)
|
||||
@@ -235,7 +235,7 @@ func TestPermissionAPI_Get(t *testing.T) {
|
||||
env.db.Create(testPerm)
|
||||
|
||||
t.Run("成功获取权限详情", func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", fmt.Sprintf("/api/v1/permissions/%d", testPerm.ID), nil)
|
||||
req := httptest.NewRequest("GET", fmt.Sprintf("/api/admin/permissions/%d", testPerm.ID), nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
@@ -247,7 +247,7 @@ func TestPermissionAPI_Get(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("权限不存在时返回错误", func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "/api/v1/permissions/99999", nil)
|
||||
req := httptest.NewRequest("GET", "/api/admin/permissions/99999", nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
|
||||
@@ -287,7 +287,7 @@ func TestPermissionAPI_Update(t *testing.T) {
|
||||
}
|
||||
|
||||
jsonBody, _ := json.Marshal(reqBody)
|
||||
req := httptest.NewRequest("PUT", fmt.Sprintf("/api/v1/permissions/%d", testPerm.ID), bytes.NewReader(jsonBody))
|
||||
req := httptest.NewRequest("PUT", fmt.Sprintf("/api/admin/permissions/%d", testPerm.ID), bytes.NewReader(jsonBody))
|
||||
req.Header.Set("Content-Type", "application/json")
|
||||
|
||||
resp, err := env.app.Test(req)
|
||||
@@ -324,7 +324,7 @@ func TestPermissionAPI_Delete(t *testing.T) {
|
||||
}
|
||||
env.db.Create(testPerm)
|
||||
|
||||
req := httptest.NewRequest("DELETE", fmt.Sprintf("/api/v1/permissions/%d", testPerm.ID), nil)
|
||||
req := httptest.NewRequest("DELETE", fmt.Sprintf("/api/admin/permissions/%d", testPerm.ID), nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
@@ -362,7 +362,7 @@ func TestPermissionAPI_List(t *testing.T) {
|
||||
}
|
||||
|
||||
t.Run("成功获取权限列表", func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "/api/v1/permissions?page=1&page_size=10", nil)
|
||||
req := httptest.NewRequest("GET", "/api/admin/permissions?page=1&page_size=10", nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
@@ -374,7 +374,7 @@ func TestPermissionAPI_List(t *testing.T) {
|
||||
})
|
||||
|
||||
t.Run("按类型过滤权限", func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", fmt.Sprintf("/api/v1/permissions?perm_type=%d", constants.PermissionTypeMenu), nil)
|
||||
req := httptest.NewRequest("GET", fmt.Sprintf("/api/admin/permissions?perm_type=%d", constants.PermissionTypeMenu), nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
@@ -425,7 +425,7 @@ func TestPermissionAPI_GetTree(t *testing.T) {
|
||||
env.db.Create(grandchildPerm)
|
||||
|
||||
t.Run("成功获取权限树", func(t *testing.T) {
|
||||
req := httptest.NewRequest("GET", "/api/v1/permissions/tree", nil)
|
||||
req := httptest.NewRequest("GET", "/api/admin/permissions/tree", nil)
|
||||
resp, err := env.app.Test(req)
|
||||
require.NoError(t, err)
|
||||
assert.Equal(t, fiber.StatusOK, resp.StatusCode)
|
||||
|
||||
Reference in New Issue
Block a user