优化结构

This commit is contained in:
Yvan
2026-08-28 00:29:40 +08:00
parent 04ff85116c
commit 03a4131f6e
118 changed files with 758 additions and 834 deletions
+5 -2
View File
@@ -24,7 +24,7 @@ func newTransactionTestData(t *testing.T) *Data {
return data
}
func TestUserAuthorityWritesAreAtomic(t *testing.T) {
func TestUserAuthorityWrites(t *testing.T) {
data := newTransactionTestData(t)
ctx := context.Background()
if err := data.gormDB.WithContext(ctx).Create(&[]authorityPO{{AuthorityID: 888, AuthorityName: "admin"}, {AuthorityID: 999, AuthorityName: "operator"}}).Error; err != nil {
@@ -44,7 +44,10 @@ func TestUserAuthorityWritesAreAtomic(t *testing.T) {
// With strict authority checks disabled, the reference implementation writes the supplied join rows
// without first requiring every role record to exist.
created.NickName = "compatible update"
if err = repo.UpdateUserWithAuthorities(ctx, created, []uint{888, 123456}); err != nil {
if err = repo.UpdateUser(ctx, created); err != nil {
t.Fatalf("user update failed: %v", err)
}
if err = repo.SetUserAuthorities(ctx, created.ID, []uint{888, 123456}); err != nil {
t.Fatalf("missing authority ID was rejected in non-strict mode: %v", err)
}
var persisted userPO