package vidser import ( "testing" "91porn-server/models/v/vidmod" ) type countingSigner struct{ n int } func (c *countingSigner) SignM3u8URL(field *string, playable, preview bool) { c.n++ } // 验证亚模块响应体不仅签直挂/精选视频,还会下钻到各专题(AllSection)内的视频—— // 这正是旧反射兜底会覆盖、改接口后最易漏掉的嵌套层级。 func TestVideoUnderSubModuleRespSignsNestedSections(t *testing.T) { c := &countingSigner{} resp := VideoUnderSubModuleResp{ AllVideoInfo: []*vidmod.VideoInfoResp{{}}, ChosenVideoInfo: []*vidmod.VideoInfoResp{{}}, AllSection: []Section{ {AllVideoInfo: []*vidmod.VideoInfoResp{{}, {}}}, }, } resp.SignM3u8(c) // (1 直挂 + 1 精选)*2 字段 + (2 专题内)*2 字段 = 8 if c.n != 8 { t.Fatalf("VideoUnderSubModuleResp should offer 8 url fields incl nested sections, got %d", c.n) } }