feat: 固定创建真实采购任务 (#112)

This commit is contained in:
chengma
2026-08-10 17:52:48 +08:00
parent 29b4491afe
commit e1b32ea024
20 changed files with 185 additions and 82 deletions
+22
View File
@@ -8,6 +8,8 @@ import (
"testing"
"github.com/gin-gonic/gin"
"cmautobuy/admin/model"
)
func sybPostContext(t *testing.T, values url.Values) (*gin.Context, *httptest.ResponseRecorder) {
@@ -147,3 +149,23 @@ func TestSybHistoryPartialPagination_翻页继续使用片段路由(t *testing.T
}
}
}
func TestPurchaseTaskOptionsFromForm_忽略篡改模式并固定Live(t *testing.T) {
context, _ := sybPostContext(t, url.Values{
"client_id": {"CLIENT-LIVE"},
"execution_mode": {"dry_run"},
"live_acknowledged": {"1"},
"live_confirmation": {"创建未付款订单"},
})
options := purchaseTaskOptionsFromForm(context, "2026-08-10T09:00:00Z")
if options.ExecutionMode != model.TaskExecutionLive {
t.Fatalf("篡改 execution_mode 不得创建演练任务,实际 %q", options.ExecutionMode)
}
if options.ClientID != "CLIENT-LIVE" || !options.LiveAcknowledged || options.LiveConfirmation != "创建未付款订单" {
t.Fatalf("真实采购确认字段读取错误: %+v", options)
}
if options.ClientSeenAfter != "2026-08-10T09:00:00Z" {
t.Fatalf("在线截止时间未传给服务层: %+v", options)
}
}