fix: 汇总后批量校验游戏权限以优化分级统计
This commit is contained in:
@@ -120,6 +120,32 @@ func TestAnalyticsChannelSearchMatchesNicknameAndKeepsScope(t *testing.T) {
|
||||
t.Fatal("wildcard keyword must not broaden the query")
|
||||
}
|
||||
}
|
||||
|
||||
func TestGameAuthorizationFiltersAggregatedFactsByPlatform(t *testing.T) {
|
||||
db, repo, scope, filter := prepareAnalyticsData(t)
|
||||
scope.Viewer = business.UserScope{SelfID: 9, OnlySelf: true}
|
||||
for _, sql := range []string{
|
||||
"INSERT INTO tab_game(source_db,id,game_name) VALUES('lx',77,'未申请游戏'),('hw',77,'其他平台游戏')",
|
||||
"INSERT INTO tab_promote_apply(source_db,promote_id,game_id,status) VALUES('hw',100,77,1)",
|
||||
"INSERT INTO tab_sw_report_day(source_db,promote_id,game_id,dedup_mode,stat_date,total_pay,game_name) VALUES('lx',100,77,0,'2026-11-01',9999999,'未申请游戏')",
|
||||
} {
|
||||
if err := db.Exec(sql).Error; err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
}
|
||||
data, err := repo.Aggregate(context.Background(), business.GameAnalytics, scope, filter)
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if len(data.Rows) == 0 {
|
||||
t.Fatal("approved games must remain visible")
|
||||
}
|
||||
for _, row := range data.Rows {
|
||||
if row.ID == 77 || row.SourceDB != "lx" {
|
||||
t.Fatal("unapproved game facts or another platform's approval escaped authorization")
|
||||
}
|
||||
}
|
||||
}
|
||||
func TestAnalyticsMissingScopeAndTablesDoNotBroaden(t *testing.T) {
|
||||
db, repo, scope, filter := prepareAnalyticsData(t)
|
||||
scope.IncludeSub = false
|
||||
|
||||
Reference in New Issue
Block a user