fix: 兼容MySQL渠道状态汇总查询并补充数据库回归

This commit is contained in:
Yvan
2026-11-05 11:14:57 +08:00
parent 413a4ebc21
commit c7d4ffbd9c
2 changed files with 27 additions and 4 deletions
@@ -128,6 +128,29 @@ func TestMySQLAlertTriggerConcurrentDeduplication(t *testing.T) {
}
}
func TestMySQLChannelStatusSummaryAndEffectivenessFilter(t *testing.T) {
db := openRehearsalMySQL(t)
if err := db.AutoMigrate(&accountPO{}, &channelPO{}); err != nil {
t.Fatal(err)
}
for i, status := range []int{0, -1, -2} {
created := int64(1000 + i)
if err := db.Create(&channelPO{ID: uint64(i + 1), SourceDB: "lx", Account: fmt.Sprintf("channel-%d", i), LockStatus: &status, CreateTime: &created}).Error; err != nil {
t.Fatal(err)
}
}
r := NewChannelRepo(testData{db})
page, err := r.List(context.Background(), business.UserScope{All: true}, business.ChannelFilter{Sources: []string{"lx"}}, business.ListLimit(1))
if err != nil || page.Total != 3 || len(page.Rows) != 1 || page.StatusCounts.Normal != 1 || page.StatusCounts.Locked != 1 || page.StatusCounts.Terminated != 1 {
t.Fatalf("MySQL全量状态汇总与分页不一致: %+v %v", page, err)
}
yes := true
page, err = r.List(context.Background(), business.UserScope{All: true}, business.ChannelFilter{Sources: []string{"lx"}, Effective: &yes})
if err != nil || page.Total != 0 {
t.Fatalf("有效端筛选不能重复关联表或漏用筛选条件: %+v %v", page, err)
}
}
func TestMySQLRegistrationIndexPreservesCastAndUsesRange(t *testing.T) {
db := openRehearsalMySQL(t)
for _, statement := range []string{