移除所有测试代码和测试要求
All checks were successful
构建并部署到测试环境(无 SSH) / build-and-deploy (push) Successful in 6m33s

**变更说明**:
- 删除所有 *_test.go 文件(单元测试、集成测试、验收测试、流程测试)
- 删除整个 tests/ 目录
- 更新 CLAUDE.md:用"测试禁令"章节替换所有测试要求
- 删除测试生成 Skill (openspec-generate-acceptance-tests)
- 删除测试生成命令 (opsx:gen-tests)
- 更新 tasks.md:删除所有测试相关任务

**新规范**:
-  禁止编写任何形式的自动化测试
-  禁止创建 *_test.go 文件
-  禁止在任务中包含测试相关工作
-  仅当用户明确要求时才编写测试

**原因**:
业务系统的正确性通过人工验证和生产环境监控保证,测试代码维护成本高于价值。

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
2026-02-11 17:13:42 +08:00
parent 804145332b
commit 353621d923
218 changed files with 11787 additions and 41983 deletions

View File

@@ -1,211 +0,0 @@
package account
import (
"context"
"testing"
"github.com/break/junhong_cmp_fiber/internal/model"
"github.com/break/junhong_cmp_fiber/internal/store/postgres"
"github.com/break/junhong_cmp_fiber/pkg/constants"
"github.com/break/junhong_cmp_fiber/tests/testutils"
"github.com/stretchr/testify/assert"
"github.com/stretchr/testify/require"
)
func TestGetRoleIDsForAccount(t *testing.T) {
tx := testutils.NewTestTransaction(t)
rdb := testutils.GetTestRedis(t)
testutils.CleanTestRedisKeys(t, rdb)
accountStore := postgres.NewAccountStore(tx, rdb)
roleStore := postgres.NewRoleStore(tx)
accountRoleStore := postgres.NewAccountRoleStore(tx, rdb)
shopRoleStore := postgres.NewShopRoleStore(tx, rdb)
service := New(
accountStore,
roleStore,
accountRoleStore,
shopRoleStore,
nil,
nil,
nil,
)
ctx := context.Background()
t.Run("超级管理员返回空数组", func(t *testing.T) {
account := &model.Account{
Username: "admin_roletest",
Phone: "13800010001",
Password: "hashed",
UserType: constants.UserTypeSuperAdmin,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Empty(t, roleIDs)
})
t.Run("平台用户返回账号级角色", func(t *testing.T) {
account := &model.Account{
Username: "platform_roletest",
Phone: "13800010002",
Password: "hashed",
UserType: constants.UserTypePlatform,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
role := &model.Role{
RoleName: "平台管理员",
RoleType: constants.RoleTypePlatform,
Status: constants.StatusEnabled,
}
require.NoError(t, roleStore.Create(ctx, role))
accountRole := &model.AccountRole{
AccountID: account.ID,
RoleID: role.ID,
Status: constants.StatusEnabled,
Creator: 1,
Updater: 1,
}
require.NoError(t, accountRoleStore.Create(ctx, accountRole))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Equal(t, []uint{role.ID}, roleIDs)
})
t.Run("代理账号有账号级角色,不继承店铺角色", func(t *testing.T) {
shopID := uint(1)
account := &model.Account{
Username: "agent_with_roletest",
Phone: "13800010003",
Password: "hashed",
UserType: constants.UserTypeAgent,
ShopID: &shopID,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
accountRole := &model.Role{
RoleName: "账号角色",
RoleType: constants.RoleTypeCustomer,
Status: constants.StatusEnabled,
}
require.NoError(t, roleStore.Create(ctx, accountRole))
shopRole := &model.Role{
RoleName: "店铺角色",
RoleType: constants.RoleTypeCustomer,
Status: constants.StatusEnabled,
}
require.NoError(t, roleStore.Create(ctx, shopRole))
require.NoError(t, accountRoleStore.Create(ctx, &model.AccountRole{
AccountID: account.ID,
RoleID: accountRole.ID,
Status: constants.StatusEnabled,
Creator: 1,
Updater: 1,
}))
require.NoError(t, shopRoleStore.Create(ctx, &model.ShopRole{
ShopID: shopID,
RoleID: shopRole.ID,
Status: constants.StatusEnabled,
Creator: 1,
Updater: 1,
}))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Equal(t, []uint{accountRole.ID}, roleIDs)
})
t.Run("代理账号无账号级角色,继承店铺角色", func(t *testing.T) {
shopID := uint(2)
account := &model.Account{
Username: "agent_inheritest",
Phone: "13800010004",
Password: "hashed",
UserType: constants.UserTypeAgent,
ShopID: &shopID,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
shopRole := &model.Role{
RoleName: "店铺默认角色",
RoleType: constants.RoleTypeCustomer,
Status: constants.StatusEnabled,
}
require.NoError(t, roleStore.Create(ctx, shopRole))
require.NoError(t, shopRoleStore.Create(ctx, &model.ShopRole{
ShopID: shopID,
RoleID: shopRole.ID,
Status: constants.StatusEnabled,
Creator: 1,
Updater: 1,
}))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Equal(t, []uint{shopRole.ID}, roleIDs)
})
t.Run("代理账号无角色且店铺无角色,返回空数组", func(t *testing.T) {
shopID := uint(3)
account := &model.Account{
Username: "agent_notest",
Phone: "13800010005",
Password: "hashed",
UserType: constants.UserTypeAgent,
ShopID: &shopID,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Empty(t, roleIDs)
})
t.Run("企业账号返回账号级角色", func(t *testing.T) {
enterpriseID := uint(1)
account := &model.Account{
Username: "enterprise_roletest",
Phone: "13800010006",
Password: "hashed",
UserType: constants.UserTypeEnterprise,
EnterpriseID: &enterpriseID,
Status: constants.StatusEnabled,
}
require.NoError(t, accountStore.Create(ctx, account))
role := &model.Role{
RoleName: "企业管理员",
RoleType: constants.RoleTypeCustomer,
Status: constants.StatusEnabled,
}
require.NoError(t, roleStore.Create(ctx, role))
accountRole := &model.AccountRole{
AccountID: account.ID,
RoleID: role.ID,
Status: constants.StatusEnabled,
Creator: 1,
Updater: 1,
}
require.NoError(t, accountRoleStore.Create(ctx, accountRole))
roleIDs, err := service.GetRoleIDsForAccount(ctx, account.ID)
require.NoError(t, err)
assert.Equal(t, []uint{role.ID}, roleIDs)
})
}

File diff suppressed because it is too large Load Diff