|
@@ -353,7 +353,7 @@ func TestDivideQuotaPrimitives(t *testing.T) {
|
|
|
|
|
|
|
|
// 级联只降:子树限制 4.00 → a(8.00) 降到 4.00
|
|
// 级联只降:子树限制 4.00 → a(8.00) 降到 4.00
|
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
|
- n, e := repo.ClampSubtreeQuota(ctx, tx, 1, 6, model.DivideTypeOneOff, money.FromCents(400))
|
|
|
|
|
|
|
+ n, e := repo.ClampSubtreeQuota(ctx, tx, root, 1, 6, model.DivideTypeOneOff, money.FromCents(400))
|
|
|
if e != nil {
|
|
if e != nil {
|
|
|
return e
|
|
return e
|
|
|
}
|
|
}
|
|
@@ -369,7 +369,7 @@ func TestDivideQuotaPrimitives(t *testing.T) {
|
|
|
}
|
|
}
|
|
|
// 再压到 6.00(高于现值)→ 不回升(影响 0 行)
|
|
// 再压到 6.00(高于现值)→ 不回升(影响 0 行)
|
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
|
- n, e := repo.ClampSubtreeQuota(ctx, tx, 1, 6, model.DivideTypeOneOff, money.FromCents(600))
|
|
|
|
|
|
|
+ n, e := repo.ClampSubtreeQuota(ctx, tx, root, 1, 6, model.DivideTypeOneOff, money.FromCents(600))
|
|
|
if e != nil {
|
|
if e != nil {
|
|
|
return e
|
|
return e
|
|
|
}
|
|
}
|
|
@@ -408,11 +408,11 @@ func TestDivideQuotaPrimitives(t *testing.T) {
|
|
|
if _, err := repo.UpdateNodeQuota(ctx, db, a, money.FromCents(-1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
if _, err := repo.UpdateNodeQuota(ctx, db, a, money.FromCents(-1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
|
t.Fatalf("负额度应 ErrBadParam,实得 %v", err)
|
|
t.Fatalf("负额度应 ErrBadParam,实得 %v", err)
|
|
|
}
|
|
}
|
|
|
- if _, err := repo.ClampSubtreeQuota(ctx, db, 5, 1, model.DivideTypeOneOff, money.FromCents(1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
|
|
|
|
|
+ if _, err := repo.ClampSubtreeQuota(ctx, db, root, 5, 1, model.DivideTypeOneOff, money.FromCents(1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
|
t.Fatalf("非法区间应 ErrBadParam,实得 %v", err)
|
|
t.Fatalf("非法区间应 ErrBadParam,实得 %v", err)
|
|
|
}
|
|
}
|
|
|
// audit A6:分成类型非法 → ErrBadParam(白名单 0/1/2)
|
|
// audit A6:分成类型非法 → ErrBadParam(白名单 0/1/2)
|
|
|
- if _, err := repo.ClampSubtreeQuota(ctx, db, 1, 6, 9, money.FromCents(1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
|
|
|
|
|
+ if _, err := repo.ClampSubtreeQuota(ctx, db, root, 1, 6, 9, money.FromCents(1)); !errors.Is(err, infraerrors.ErrBadParam) {
|
|
|
t.Fatalf("非法分成类型应 ErrBadParam,实得 %v", err)
|
|
t.Fatalf("非法分成类型应 ErrBadParam,实得 %v", err)
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
@@ -436,7 +436,7 @@ func TestClampSubtreeQuotaTypeFilter(t *testing.T) {
|
|
|
ctx := context.Background()
|
|
ctx := context.Background()
|
|
|
|
|
|
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
|
- n, e := repo.ClampSubtreeQuota(ctx, tx, 1, 6, model.DivideTypeOneOff, money.FromCents(400))
|
|
|
|
|
|
|
+ n, e := repo.ClampSubtreeQuota(ctx, tx, root, 1, 6, model.DivideTypeOneOff, money.FromCents(400))
|
|
|
if e != nil {
|
|
if e != nil {
|
|
|
return e
|
|
return e
|
|
|
}
|
|
}
|
|
@@ -456,7 +456,7 @@ func TestClampSubtreeQuotaTypeFilter(t *testing.T) {
|
|
|
|
|
|
|
|
// divideType=0(admin 全量场景)→ 两种类型一起压
|
|
// divideType=0(admin 全量场景)→ 两种类型一起压
|
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
if err := runner.WithinTx(ctx, func(tx *gorm.DB) error {
|
|
|
- n, e := repo.ClampSubtreeQuota(ctx, tx, 1, 6, 0, money.FromCents(200))
|
|
|
|
|
|
|
+ n, e := repo.ClampSubtreeQuota(ctx, tx, root, 1, 6, 0, money.FromCents(200))
|
|
|
if e != nil {
|
|
if e != nil {
|
|
|
return e
|
|
return e
|
|
|
}
|
|
}
|