二次编辑商品
This commit is contained in:
@@ -3,6 +3,9 @@ package listing
|
||||
import (
|
||||
"encoding/json"
|
||||
"testing"
|
||||
|
||||
"hfb_sys/backend/internal/database"
|
||||
"hfb_sys/backend/internal/model"
|
||||
)
|
||||
|
||||
func TestConsumableValueOnlyCountsChargedResources(t *testing.T) {
|
||||
@@ -105,6 +108,46 @@ func TestCreateRequiresPublishAgreements(t *testing.T) {
|
||||
}
|
||||
}
|
||||
|
||||
func TestRepositoryUpdateAllowsOfflineListingResubmit(t *testing.T) {
|
||||
db := database.NewTestDB()
|
||||
if err := db.AutoMigrate(&model.GameAccount{}, &model.RentalListing{}); err != nil {
|
||||
t.Fatalf("failed to migrate test db: %v", err)
|
||||
}
|
||||
repo := NewRepository(db)
|
||||
req := CreateRequest{
|
||||
Title: "测试账号",
|
||||
ServerRegion: "QQ",
|
||||
LoginPlatform: "QQ账号密码",
|
||||
RankLevel: "黑鹰",
|
||||
HafCoinAmount: 100000000,
|
||||
PriceCent: 10000,
|
||||
DepositAmountCent: 50000,
|
||||
ScreenshotURLS: []string{"https://example.com/a.png"},
|
||||
AssetSummary: map[string]any{
|
||||
"online_time": map[string]any{"start": "09:00", "end": "23:00"},
|
||||
},
|
||||
}
|
||||
created, err := repo.Create(t.Context(), 1, req, false)
|
||||
if err != nil {
|
||||
t.Fatalf("failed to create listing: %v", err)
|
||||
}
|
||||
if _, err := repo.Offline(t.Context(), 1, created.ID); err != nil {
|
||||
t.Fatalf("failed to offline listing: %v", err)
|
||||
}
|
||||
|
||||
req.Title = "二次编辑账号"
|
||||
updated, err := repo.Update(t.Context(), 1, created.ID, req, true)
|
||||
if err != nil {
|
||||
t.Fatalf("expected offline listing can be updated, got %v", err)
|
||||
}
|
||||
if updated.Title != "二次编辑账号" {
|
||||
t.Fatalf("expected title updated, got %q", updated.Title)
|
||||
}
|
||||
if updated.Status != "draft" || updated.ReviewStatus != "pending" {
|
||||
t.Fatalf("expected draft/pending after resubmit, got %s/%s", updated.Status, updated.ReviewStatus)
|
||||
}
|
||||
}
|
||||
|
||||
func TestApplySellerListingPriceUsesSellerTotalPrice(t *testing.T) {
|
||||
item := &ListingDTO{
|
||||
PriceCent: 23800,
|
||||
|
||||
Reference in New Issue
Block a user