fix: pass operator id to audit logs
This commit is contained in:
@@ -105,7 +105,8 @@ func (s *SuperTestSuite) Test_WithdrawalApproval() {
|
||||
database.Truncate(ctx, s.DB, models.TableNameOrder, models.TableNameUser, models.TableNameTenantLedger)
|
||||
|
||||
u := &models.User{Username: "user_w", Balance: 1000} // Initial 10.00
|
||||
models.UserQuery.WithContext(ctx).Create(u)
|
||||
admin := &models.User{Username: "admin_w"}
|
||||
models.UserQuery.WithContext(ctx).Create(u, admin)
|
||||
|
||||
// Create Withdrawal Order (Pending)
|
||||
o1 := &models.Order{
|
||||
@@ -124,7 +125,7 @@ func (s *SuperTestSuite) Test_WithdrawalApproval() {
|
||||
})
|
||||
|
||||
Convey("should approve withdrawal", func() {
|
||||
err := Super.ApproveWithdrawal(ctx, o1.ID)
|
||||
err := Super.ApproveWithdrawal(ctx, admin.ID, o1.ID)
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
oReload, _ := models.OrderQuery.WithContext(ctx).Where(models.OrderQuery.ID.Eq(o1.ID)).First()
|
||||
@@ -145,7 +146,7 @@ func (s *SuperTestSuite) Test_WithdrawalApproval() {
|
||||
// But here we set balance manually to 1000. Let's assume it was 1200 before.
|
||||
// Current balance 1000. Refund 200 -> Expect 1200.
|
||||
|
||||
err := Super.RejectWithdrawal(ctx, o2.ID, "Invalid account")
|
||||
err := Super.RejectWithdrawal(ctx, admin.ID, o2.ID, "Invalid account")
|
||||
So(err, ShouldBeNil)
|
||||
|
||||
oReload, _ := models.OrderQuery.WithContext(ctx).Where(models.OrderQuery.ID.Eq(o2.ID)).First()
|
||||
@@ -158,6 +159,7 @@ func (s *SuperTestSuite) Test_WithdrawalApproval() {
|
||||
l, _ := models.TenantLedgerQuery.WithContext(ctx).Where(models.TenantLedgerQuery.OrderID.Eq(o2.ID)).First()
|
||||
So(l, ShouldNotBeNil)
|
||||
So(l.Type, ShouldEqual, consts.TenantLedgerTypeAdjustment)
|
||||
So(l.OperatorUserID, ShouldEqual, admin.ID)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user