test(goauto): seed current purchase rule in SYB fixtures (#127)

This commit is contained in:
QiuSW
2026-08-29 21:58:23 +08:00
parent 1ec895b8e6
commit 5d85625905
@@ -9,6 +9,7 @@ import (
"go-admin/app/goauto/migrations"
"go-admin/app/goauto/models"
"go-admin/app/goauto/purchasecontract"
"go-admin/app/goauto/shopeeproduct"
"go-admin/app/goauto/sybimport"
@@ -26,6 +27,13 @@ func openTestDB(t *testing.T) *gorm.DB {
if err := migrations.Migrate(db); err != nil {
t.Fatalf("migrate: %v", err)
}
currentRule := models.PurchaseRule{Name: "测试当前采购规则", ContentJSON: string(purchasecontract.DefaultLiveRule())}
if err := db.Create(&currentRule).Error; err != nil {
t.Fatalf("seed purchase rule: %v", err)
}
if err := db.Create(&models.PurchaseRuleSetting{ID: 1, RuleID: currentRule.ID}).Error; err != nil {
t.Fatalf("seed current purchase rule: %v", err)
}
return db
}