修复 Context 改造后的编译问题

This commit is contained in:
yml2213
2026-06-10 09:43:49 +08:00
parent b377f8350b
commit 334436f381
13 changed files with 193 additions and 189 deletions
+10 -9
View File
@@ -1,6 +1,7 @@
package e2e
import (
"context"
"database/sql"
"fmt"
"os"
@@ -45,7 +46,7 @@ func TestRentalFullFlowWithMockPayment(t *testing.T) {
}
orderDTO := mustCreateOrder(t, services.order, renter.ID, adjusted.ID)
paymentDTO, err := services.payment.Start(renter.ID, orderDTO.ID, payment.StartPaymentRequest{}, "127.0.0.1")
paymentDTO, err := services.payment.Start(t.Context(), renter.ID, orderDTO.ID, payment.StartPaymentRequest{}, "127.0.0.1")
if err != nil {
t.Fatalf("启动 mock 支付失败: %v", err)
}
@@ -115,7 +116,7 @@ func TestArbitrationReleaseDepositDoesNotRepublishListing(t *testing.T) {
listingDTO := createListingUnderReview(t, services.listing, owner.ID)
approved := adjustAndApproveListing(t, services.listing, adminID, listingDTO.ID)
orderDTO := mustCreateOrder(t, services.order, renter.ID, approved.ID)
if _, err := services.payment.Start(renter.ID, orderDTO.ID, payment.StartPaymentRequest{}, "127.0.0.1"); err != nil {
if _, err := services.payment.Start(t.Context(), renter.ID, orderDTO.ID, payment.StartPaymentRequest{}, "127.0.0.1"); err != nil {
t.Fatalf("启动 mock 支付失败: %v", err)
}
if _, err := services.order.SubmitHandoff(owner.ID, orderDTO.ID, order.SubmitHandoffRequest{Content: "账号:demo,密码:demo-pass"}); err != nil {
@@ -171,7 +172,7 @@ func TestArbitrationReleaseDepositDoesNotRepublishListing(t *testing.T) {
assertEqual(t, "仲裁退款状态", orderRow.RefundStatus, "refunded")
assertEqual(t, "仲裁退款金额", orderRow.RefundAmountCent, int64(15000))
walletAccount, err := services.wallet.Account(owner.ID)
walletAccount, err := services.wallet.Account(t.Context(), owner.ID)
if err != nil {
t.Fatalf("读取号主钱包失败: %v", err)
}
@@ -209,14 +210,14 @@ func newFlowServices(db *gorm.DB) flowServices {
paymentRepo := payment.NewRepository(db, configRepo, orderRepo, walletRepo)
disputeRepo := dispute.NewRepository(db)
orderRepo.SetRefundFunc(func(orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
refund, err := paymentRepo.StartRefund(orderID, refundAmountCent, bizType, remark)
refund, err := paymentRepo.StartRefund(context.Background(), orderID, refundAmountCent, bizType, remark)
if err != nil {
return "", err
}
return refund.Status, nil
})
disputeRepo.SetRefundFunc(func(orderID uint64, refundAmountCent int64, bizType string, remark string) (string, error) {
refund, err := paymentRepo.StartRefund(orderID, refundAmountCent, bizType, remark)
refund, err := paymentRepo.StartRefund(context.Background(), orderID, refundAmountCent, bizType, remark)
if err != nil {
return "", err
}
@@ -238,7 +239,7 @@ func newFlowServices(db *gorm.DB) flowServices {
type fixedConfig map[string]string
func (c fixedConfig) FindValue(key string) (string, error) {
func (c fixedConfig) FindValue(ctx context.Context, key string) (string, error) {
return c[key], nil
}
@@ -392,7 +393,7 @@ func createOwnerPaymentAccount(t *testing.T, service *paymentaccount.Service, ow
func createListingUnderReview(t *testing.T, service *listing.Service, ownerID uint64) *listing.ListingDTO {
t.Helper()
dto, err := service.Create(ownerID, listing.CreateRequest{
dto, err := service.Create(t.Context(), ownerID, listing.CreateRequest{
Title: "E2E 烽火地带账号",
Description: "用于完整链路测试",
ServerRegion: "烽火地带",
@@ -490,7 +491,7 @@ func assertFinanceDashboard(t *testing.T, service *adminfinance.Service, orderNo
func assertWalletAndWithdrawal(t *testing.T, walletService *wallet.Service, withdrawalService *withdrawal.Service, ownerID uint64, adminID uint64, paymentAccountID uint64) {
t.Helper()
accountBefore, err := walletService.Account(ownerID)
accountBefore, err := walletService.Account(t.Context(), ownerID)
if err != nil {
t.Fatalf("读取号主钱包失败: %v", err)
}
@@ -525,7 +526,7 @@ func assertWalletAndWithdrawal(t *testing.T, walletService *wallet.Service, with
assertEqual(t, "提现完成状态", paid.Status, "completed")
assertEqual(t, "提现到账金额", paid.ActualAmountCent, int64(10000))
accountAfter, err := walletService.Account(ownerID)
accountAfter, err := walletService.Account(t.Context(), ownerID)
if err != nil {
t.Fatalf("读取提现后钱包失败: %v", err)
}