完善服务端材质渲染(未测试),删除profile表中不必要的isActive字段及相关接口
This commit is contained in:
@@ -80,15 +80,6 @@ func TestProfileService_StatusValidation(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestProfileService_IsActiveDefault 测试Profile默认活跃状态
|
||||
func TestProfileService_IsActiveDefault(t *testing.T) {
|
||||
// 新创建的档案默认为活跃状态
|
||||
isActive := true
|
||||
if !isActive {
|
||||
t.Error("新创建的Profile应该默认为活跃状态")
|
||||
}
|
||||
}
|
||||
|
||||
// TestUpdateProfile_PermissionCheck 测试更新Profile的权限检查逻辑
|
||||
func TestUpdateProfile_PermissionCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
@@ -191,38 +182,6 @@ func TestDeleteProfile_PermissionCheck(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestSetActiveProfile_PermissionCheck 测试设置活跃Profile的权限检查
|
||||
func TestSetActiveProfile_PermissionCheck(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
profileUserID int64
|
||||
requestUserID int64
|
||||
wantErr bool
|
||||
}{
|
||||
{
|
||||
name: "用户ID匹配,允许设置",
|
||||
profileUserID: 1,
|
||||
requestUserID: 1,
|
||||
wantErr: false,
|
||||
},
|
||||
{
|
||||
name: "用户ID不匹配,拒绝设置",
|
||||
profileUserID: 1,
|
||||
requestUserID: 2,
|
||||
wantErr: true,
|
||||
},
|
||||
}
|
||||
|
||||
for _, tt := range tests {
|
||||
t.Run(tt.name, func(t *testing.T) {
|
||||
hasError := tt.profileUserID != tt.requestUserID
|
||||
if hasError != tt.wantErr {
|
||||
t.Errorf("Permission check failed: got %v, want %v", hasError, tt.wantErr)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
// TestCheckProfileLimit_Logic 测试Profile数量限制检查逻辑
|
||||
func TestCheckProfileLimit_Logic(t *testing.T) {
|
||||
tests := []struct {
|
||||
@@ -642,8 +601,8 @@ func TestProfileServiceImpl_GetByUserID(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
// TestProfileServiceImpl_Update_And_SetActive 测试 Update 与 SetActive
|
||||
func TestProfileServiceImpl_Update_And_SetActive(t *testing.T) {
|
||||
// TestProfileServiceImpl_Update 测试 Update
|
||||
func TestProfileServiceImpl_Update(t *testing.T) {
|
||||
profileRepo := NewMockProfileRepository()
|
||||
userRepo := NewMockUserRepository()
|
||||
logger := zap.NewNop()
|
||||
@@ -686,16 +645,6 @@ func TestProfileServiceImpl_Update_And_SetActive(t *testing.T) {
|
||||
if _, err := svc.Update(ctx, "u1", 1, stringPtr("Duplicate"), nil, nil); err == nil {
|
||||
t.Fatalf("Update 在名称重复时应返回错误")
|
||||
}
|
||||
|
||||
// SetActive 正常
|
||||
if err := svc.SetActive(ctx, "u1", 1); err != nil {
|
||||
t.Fatalf("SetActive 正常情况失败: %v", err)
|
||||
}
|
||||
|
||||
// SetActive 无权限
|
||||
if err := svc.SetActive(ctx, "u1", 2); err == nil {
|
||||
t.Fatalf("SetActive 在无权限时应返回错误")
|
||||
}
|
||||
}
|
||||
|
||||
// TestProfileServiceImpl_CheckLimit_And_GetByNames 测试 CheckLimit / GetByNames / GetByProfileName
|
||||
|
||||
Reference in New Issue
Block a user