fix(publish): 补齐实体键唯一索引的测试覆盖与守卫消息
This commit is contained in:
@ -9,6 +9,7 @@ package repository
|
||||
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"testing"
|
||||
@ -39,7 +40,13 @@ func applyMigration(t *testing.T, db *gorm.DB, name string) {
|
||||
func seedRunway(t *testing.T, db *gorm.DB, status string, year uint16) uint32 {
|
||||
t.Helper()
|
||||
now := uint32(1_800_000_000)
|
||||
rw := model.BrandRunway{TitleEn: "view-test", Year: year, Status: status, CreatedAt: now, UpdatedAt: now}
|
||||
// 实体键必须非空且按 year 派生:2026-09-22-03 的唯一索引落库后,brand_id=0 且
|
||||
// season_code / collection_type 均为空会让同一次运行里的多条种子行(乃至上次运行
|
||||
// 未清理的遗留行)被当成「同一实体」而互相冲突,失败点还会伪装成迁移体检。
|
||||
rw := model.BrandRunway{
|
||||
TitleEn: "view-test", Year: year, Status: status, CreatedAt: now, UpdatedAt: now,
|
||||
SeasonCode: fmt.Sprintf("T%04d", year), CollectionType: "t",
|
||||
}
|
||||
if err := db.Create(&rw).Error; err != nil {
|
||||
t.Fatalf("插入走秀失败: %v", err)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user