统一订单资产状态变更

This commit is contained in:
yml
2026-06-09 20:11:28 +08:00
parent 0990652f8b
commit 4c2199df58
5 changed files with 125 additions and 78 deletions
@@ -140,14 +140,29 @@ func TestCalculateDepositWaiverUsesSharedRemainingQuota(t *testing.T) {
}
}
func TestArchiveListingAfterCheckoutMovesListingOffline(t *testing.T) {
// This test is purely for contract documentation; no behavior is tested yet.
// When implementing auto-archive behavior:
// - Call should succeed for renting/overdue/pending_checkout_confirm/pending_checkout_accept orders
// - Listing status should be set to "archived" or "offline"
// - In-transaction flag should be cleared
// - Order should enter completed or closed state
_ = time.Now()
func TestArchiveAssetsMovesListingOffline(t *testing.T) {
now := time.Now()
listing := model.RentalListing{
Status: listingStatusRented,
InTransaction: true,
PublishedAt: &now,
}
account := model.GameAccount{Status: accountStatusRented}
archiveAssets(&listing, &account)
if listing.Status != listingStatusOffline {
t.Fatalf("listing.Status = %q, want %q", listing.Status, listingStatusOffline)
}
if listing.InTransaction {
t.Fatal("listing.InTransaction = true, want false")
}
if listing.PublishedAt != nil {
t.Fatal("listing.PublishedAt is not nil")
}
if account.Status != accountStatusOffline {
t.Fatalf("account.Status = %q, want %q", account.Status, accountStatusOffline)
}
}
func TestNewOrderNoUsesShanghaiTimeWhenLocalIsUTC(t *testing.T) {