优化结构
This commit is contained in:
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user