init: hgmj server initial commit

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
2026-10-08 16:50:13 +08:00
co-authored by Claude Opus 4.7
commit 625e89c15d
1870 changed files with 254090 additions and 0 deletions
+35
View File
@@ -0,0 +1,35 @@
package vidmod
import "testing"
// countingSigner 记录被交出的地址字段个数,用于验证各响应体 SignM3u8 的字段枚举是否完整。
type countingSigner struct{ n int }
func (c *countingSigner) SignM3u8URL(field *string, playable, preview bool) { c.n++ }
func TestVideoInfoOffersThreeFields(t *testing.T) {
c := &countingSigner{}
(&VideoInfo{}).SignM3u8(c)
if c.n != 3 { // sourceURL + h265Url + previewURL
t.Fatalf("VideoInfo should offer 3 url fields, got %d", c.n)
}
}
func TestVideoInfoRespOffersTwoFields(t *testing.T) {
c := &countingSigner{}
(&VideoInfoResp{}).SignM3u8(c)
if c.n != 2 { // sourceURL + h265Url(无 previewURL)
t.Fatalf("VideoInfoResp should offer 2 url fields, got %d", c.n)
}
}
func TestNilVideosAreSafe(t *testing.T) {
c := &countingSigner{}
var v *VideoInfo
v.SignM3u8(c) // nil 接收者不应 panic
SignM3u8Infos(c, []*VideoInfo{nil})
SignM3u8Resps(c, []*VideoInfoResp{nil})
if c.n != 0 {
t.Fatalf("nil videos must not offer any field, got %d", c.n)
}
}