优化
This commit is contained in:
@@ -63,6 +63,25 @@ func TestUserAuthorityWritesAreAtomic(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestSetUserAuthoritiesRejectsMissingUser(t *testing.T) {
|
||||
data := newTransactionTestData(t)
|
||||
ctx := context.Background()
|
||||
if err := data.gormDB.WithContext(ctx).Create(&authorityPO{AuthorityID: 888, AuthorityName: "admin"}).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
repo := &userRepo{data: data}
|
||||
if err := repo.SetUserAuthorities(ctx, 999999, []uint{888}); err == nil || err.Error() != "查询用户数据失败" {
|
||||
t.Fatalf("expected the compatible missing-user error, got %v", err)
|
||||
}
|
||||
var links int64
|
||||
if err := data.gormDB.WithContext(ctx).Model(&userAuthorityPO{}).Where("sys_user_id = ?", 999999).Count(&links).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if links != 0 {
|
||||
t.Fatalf("unexpected authority links for missing user: %d", links)
|
||||
}
|
||||
}
|
||||
|
||||
func TestDictionaryImportKeepsHierarchyInOneTransaction(t *testing.T) {
|
||||
data := newTransactionTestData(t)
|
||||
ctx := context.Background()
|
||||
|
||||
Reference in New Issue
Block a user